[Database] Sql Server visualization tool SSMS conditions and SQL panes and version information

2023, Week 34, Article 1. Give yourself a goal, and then insist that there will always be a receipt, if you don’t believe me, try it!
SQL SERVER officially has a database visualization management tool SSMS, so most of them will use SSMS. The previous version was directly bundled, and
it was included after the installation was completed. The latest version does not need to be bundled, and the corresponding version needs to be downloaded and installed separately.

insert image description here

1. Visualization tools

In addition to Microsoft SQL Server Management Studio (SSMS), there are many other visual tools for managing and querying SQL Server databases.
Here are some commonly used visualization tools:

1.1、Azure Data Studio

This is a lightweight cross-platform database management tool that can be used to connect and manage multiple databases, including SQL Server, Azure SQL Database, etc.

1.2、Visual Studio Code

Although it is a general-purpose code editor, by installing the appropriate extensions, such as the mssql extension, you can connect to and query SQL Server databases in Visual Studio Code.

1.3、DBeaver

This is a feature-rich open source database management tool that supports multiple database platforms, including SQL Server. It provides an intuitive user interface and powerful query functions.

1.4、SQL Server Data Tools (SSDT)

This is a plug-in for Visual Studio that provides support for SQL Server database development. It provides functions such as database project, model design, data comparison and publishing.

1.5、dbForge Studio for SQL Server

This is a powerful commercial database management tool that provides a wide range of features, including database design, query building, data import and export, and more.

1.6、Navicat for SQL Server

This is another commercial database management tool that supports multiple database platforms, including SQL Server. It offers an intuitive user interface and a rich feature set.

These visualization tools have different functions and user interfaces, and you can choose the tool that suits you according to your personal preferences and needs.
No matter which tool you choose, you can easily manage and query SQL Server databases.

2. SSMS version

Microsoft SQL Server Management Studio (SSMS) is an integrated environment for managing and operating Microsoft SQL Server databases.
It provides a graphical user interface for operations such as database design, query, management, and tuning.

Each release of SSMS introduces some new features and improvements, here are some common major differences between the releases

1.1、SQL Server 2008 SSMS

Released in 2008, this is one of the earliest versions of SSMS.
SSMS 2008 brings many new features and improvements, including:
1) IntelliSense
provides automatic code completion and syntax checking functions, which can write and debug SQL queries and scripts more quickly.
2) Multi-file query editor
Allows to open and edit multiple query files at the same time, which is convenient for comparison and debugging between multiple queries.
3) Dependency Viewer
Allows you to view the dependencies between database objects, making it easy to understand the dependencies and influences between objects.
4) Activity Monitor
Provides real-time monitoring and analysis of database activity and performance, including query execution plans, lock and blocking information, etc.

1.2、SQL Server 2012 SSMS

Released on March 7, 2012, this version introduces some new features, such as local execution plan preview, group window function syntax highlighting, column
selector, and support for some new SQL Server 2012 features.

1.3、SQL Server 2014 SSMS

Released on April 1, 2014, this version introduces more features and improvements, including cache scaling mode, multi-server queries, and more.

1.4、SQL Server 2016 SSMS

Released on June 1, 2016, this version adds support for many new features of SQL Server 2016, such as Temporal tables, dynamic data masking, row-level security, and more.

1.5、SQL Server 2017 SSMS

Released on October 2, 2017, this version introduces some new features, such as drawing, automatic correlation, automatic self-test, etc.

1.6、SQL Server 2019 SSMS

Released on November 4, 2019, this version adds support for new features of SQL Server 2019, such as Big Data Clusters, encrypted data pages, intelligent query processing, and more.

Note that each version of SSMS supports a corresponding version of the SQL Server database, but usually newer versions of SSMS are also backward compatible with older versions of the database.
It is recommended to use the latest version of SSMS for more features and performance improvements.

Note that the above are just differences between some major versions and are not detailed.
Friends can refer to Microsoft's official documentation or more detailed release notes to learn about the specific improvements and new features of each version.

3. Common system tables

In SQL Server, system tables are special tables used to store database metadata and system information. The following are some common SQL Server system tables:

1.1、sys.objects

This table contains information about all objects in the database such as tables, views, stored procedures, triggers, etc., including their names, types, creation dates, etc.

1.2、sys.columns

This table stores column information of all tables in the database, including column names, data types, lengths, etc.

1.3、sys.tables

This table contains information about all tables in the database, including table names, schemas, types, creation dates, etc.

1.4、sys.views

This table stores all view information in the database, including view name, definition, creation date, etc.

1.5、sys.procedures

This table contains information about all stored procedures in the database, such as the stored procedure's name, definition, creation date, and so on.

1.6、sys.triggers

This table contains information about all triggers in the database, including the name of the trigger, associated table, event type, etc.

1.7、sys.indexes

This table stores information about all indexes in the database, including the name of the index, the table it belongs to, and the columns it belongs to.

1.8、sys.schemas

This table contains all schema information in the database, including schema name, owner, etc.

1.9、sys.databases

This table stores information about all databases, including the database's name, creation date, status, and so on.

1.10、sys.sysprocesses

This table provides information about each process running on the current instance of SQL Server, including the process ID, status, currently executing SQL statement, and more.

The above are some common SQL Server system tables, which can provide important information about the database structure, objects and metadata to help with database management, query and monitoring.
Note that this is only a small subset of system tables and may vary by SQL Server version and configuration.

4. SQL query system table

4.1. Query all tables in the database

To query all tables in a SQL Server database, you can use the following SQL query:

USE YourDatabaseName; -- 替换为你要查询的数据库名称
SELECT *
FROM sys.tables;

In the above query, you need to replace "YourDatabaseName" with the actual name of the database you are querying.
The query sys.tablesretrieves information about all tables in the database from the system tables and returns that information.

Note that this query will return a result set containing all tables, including system tables and user tables.
If you only want to return the users table, you can add an additional filter to the query, for example:

USE YourDatabaseName; -- 替换为你要查询的数据库名称
SELECT *
FROM sys.tables
WHERE is_ms_shipped = 0;

By is_ms_shipped = 0adding the condition to the query, system tables can be excluded and only user tables returned.

Alternatively, you can use the SSMS GUI to get all the tables in the database. In SSMS,
expand the database object (visible in the Object Explorer pane), then select the Tables folder, and you can see all the tables in that database.

4.2. Query table fields and notes

To query the fields and field descriptions of a SQL Server database table, you can use the following SQL query:

USE 数据库名; -- 替换为你要查询的数据库名称
SELECT 
    T.TABLE_NAME AS 表名,
    C.COLUMN_NAME AS 字段名,
    P.VALUE AS 字段说明
FROM INFORMATION_SCHEMA.TABLES AS T
INNER JOIN INFORMATION_SCHEMA.COLUMNS AS C ON T.TABLE_NAME = C.TABLE_NAME
LEFT JOIN (
    SELECT 
        MAJOR_ID,
        MINOR_ID,
        NAME,
        VALUE
    FROM SYS.EXTENDED_PROPERTIES 
    WHERE NAME = 'MS_Description'
) AS P ON P.MAJOR_ID = OBJECT_ID(T.TABLE_NAME) AND P.MINOR_ID = COLUMNPROPERTY(OBJECT_ID(T.TABLE_NAME), C.COLUMN_NAME, 'ColumnID')
WHERE T.TABLE_TYPE = 'BASE TABLE' and T.TABLE_NAME='你的表名' -- 只查询基本表
ORDER BY T.TABLE_NAME, C.ORDINAL_POSITION;

insert image description here

In the query, replace "database name" with the actual database name you want to query.
The query retrieves information on table fields in the database by joining the INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.COLUMNS system views.
Then, use a subquery to get the field's description information.
The query result includes table name, field name and field description.
Use the WHERE clause to filter as needed, such as querying only basic tables or specific tables.
Query results are sorted by table name and field order.
Note that this query uses the MS_Description extended attribute by default to store field descriptions.
If you are using another name to store description information in the database, you need to modify the NAME = 'MS_Description' condition in the WHERE subquery accordingly.

Guess you like

Origin blog.csdn.net/lmy_520/article/details/132273387