View the Table Definition
Applies to: SQL Server 2016 (13.x) and later Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW)
You can display properties for a table in SQL Server by using SQL Server Management Studio or Transact-SQL.
Permissions
You can only see properties in a table if you either own the table or have been granted permissions to that table.
Using SQL Server Management Studio
To show table properties in the Properties window
In Object Explorer, select the table for which you want to show properties.
Right-click the table and select Properties from the shortcut menu. For more information, see Table Properties - SSMS.
To generate the CREATE TABLE script for an existing table
You can script out existing objects from the Object Explorer in SSMS. For more information, see Generate Scripts.
Using Transact-SQL
To show table properties
In Object Explorer, connect to an instance of Database Engine.
On the Standard bar, select New Query.
Copy and paste the following example into the query window and select Execute. The example executes the system stored procedure
sp_help
to return all column information for the specified object.
EXEC sp_help 'dbo.mytable';
For more information, see sp_help.
By default, SSMS maps a keyboard shortcut for sp_help
to the Alt-F1
. Highlight the name of the object in a script you want to see, for example dbo.mytable
, and hit Alt-F1
to execute the previous script sample. For more information, see SSMS keyboard shortcuts.
You could alternatively query the system catalog views directly to query object metadata information about tables, schema, and columns. For example:
SELECT s.name as schema_name, t.name as table_name, c.* FROM sys.columns AS c
INNER JOIN sys.tables AS t ON t.object_id = c.object_id
INNER JOIN sys.schemas AS s ON s.schema_id = t.schema_id
WHERE t.name = 'mytable' AND s.name = 'dbo';
Next Steps
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla