25 lines
792 B
SQL
25 lines
792 B
SQL
-- 1、查询所有表的名称
|
|
-- 方法一:
|
|
select name from sys.tables
|
|
-- 方法二:
|
|
select table_name from information_schema.tables
|
|
|
|
|
|
-- 2、查询 test_01 表的所有字段
|
|
-- 方法一:
|
|
Select name FROM SysColumns Where id=Object_Id('test_01')
|
|
-- 方法二:
|
|
select column_name from information_schema.columns where table_name = '销售合同_20240523'
|
|
|
|
-- 3、查询 test_01 表的所有字段以及字段类型
|
|
select table_name,column_name,data_type
|
|
from information_schema.columns
|
|
where table_name = 'test_01'
|
|
|
|
|
|
-- 4、查看 test_01 表的字段以及字段的注释
|
|
select a.name table_name,b.name column_name,C.value column_description
|
|
from sys.tables a
|
|
inner join sys.columns b on b.object_id = a.object_id
|
|
left join sys.extended_properties c on c.major_id = b.object_id and c.minor_id = b.column_id
|
|
where a.name = 'test_01' |