【澳门金沙vip】Oracle|sql server|access 数据Curry的装有表名,字段名

复制代码 代码如下: SELECT Name FROM
Master..SysDatabases ORDER BY Name –获得所有数据库 SELECT Name FROM
[数据库名]..SysObjects Where XType=’U’ ORDER BY Name
–获得数据库下的所有表 select name from syscolumns where
id=object_id(N’表名’) –获得表里的所有字段
–获取表字段名、类型、递增、描述 复制代码
代码如下: select syscolumns.name as 字段,syscolumns.isnullable as
可否为空,systypes.name as SQL类型,
ISNULL(sys.identity_columns.is_identity,0) as 递增,
ISNULL(sys.extended_properties.value,”) as 描述 from sysobjects join
syscolumns on sysobjects.id = syscolumns.id join systypes on
syscolumns.xusertype = systypes.xusertype left join
sys.identity_columns on sys.identity_columns.object_id =
syscolumns.id and sys.identity_columns.column_id = syscolumns.colid
left join sys.extended_properties on sys.extended_properties.major_id
= syscolumns.id and sys.extended_properties.minor_id =
syscolumns.colid where sysobjects.name = ‘表名’

Oracle|sql server|access 数据库教程里的所有表名,字段名

select * from user_tables where table_name = ‘用户名’

如果是用该用户登录使用以下语句:SELECT *FROM
USER_TABLES;如果是用其他用户:SELECT * FROM ALL_TABLES WHERE
OWNER=’USER_NAME’
首先,第一句:是查询的该用户下的所有表吗?一般的普通用户,只是授予了connect

resource权限,也可以查看部分系统表吗?怎样查看该用户下的自己创建的所有表呢?其次,第二句,当我以sys身份登录时,怎么不可以使用这一句呢?SELECT
*FROM ALL_TABLES WHERE OWNER=’xiaoming’

SQL SERVER 查看所有表名:select name from sysobjects where type=’U’

查询表的所有字段名:Select name from syscolumns Where
ID=OBJECT_ID(‘表名’)

select * from information_schema.tablesselect * from
information_schema.viewsselect * from information_schema.columns

ACCESS

查看所有表名:select name from MSysObjects where type=1 and flags=0

MSysObjects是系统对象,默认情况是隐藏的。通过工具、选项、视图、显示、系统对象可以使之显示出来。

参考:sql server获取库名,表名

1.获取表的基本字段属性

–获取SqlServer中表结构 SELECT
syscolumns.name,systypes.name,syscolumns.isnullable,syscolumns.length
FROM syscolumns, systypes WHERE syscolumns.xusertype =
systypes.xusertype AND syscolumns.id = object_id(‘你的表名’)

2.获取字段的描述信息

–获取SqlServer中表结构 主键,及描述declare @table_name as
varchar(max)set @table_name = ‘你的表名’ select sys.columns.name,
sys.types.name, sys.columns.max_length, sys.columns.is_nullable,
(select count(*) from sys.identity_columns where
sys.identity_columns.object_id = sys.columns.object_id and
sys.columns.column_id = sys.identity_columns.column_id) as
is_identity , (select value from sys.extended_properties where
sys.extended_properties.major_id = sys.columns.object_id and
sys.extended_properties.minor_id = sys.columns.column_id) as
description from sys.columns, sys.tables, sys.types where
sys.columns.object_id = sys.tables.object_id and
sys.columns.system_type_id=sys.types.system_type_id and
sys.tables.name=@table_name order by sys.columns.column_id

3.单独查询表的递增字段

–单独查询表递增字段select [name] from syscolumns where
id=object_id(N’你的表名’) and COLUMNPROPERTY(id,name,’IsIdentity’)=1

4.获取表的主外键

–获取表主外键约束exec sp_helpconstraint ‘你的表名’ ;

5.相当完整的表结构查询

–很全面的表结构exec sp_helpconstraint ‘你的表名’ ;

SELECT 表名 = CASE a.colorder WHEN 1 THEN c.name ELSE ” END,

序 = a.colorder,

字段名= a.name,

标识 = CASE COLUMNPROPERTY(a.id,a.name,’IsIdentity’) WHEN 1 THEN ” ELSE
” END,

主键 = CASE

WHEN EXISTS ( SELECT * FROM sysobjects WHERE xtype=’PK’

AND name IN (SELECT [name] FROM sysindexes WHERE id=a.id

AND indid IN (SELECT indid FROM sysindexkeys WHERE id=a.id

AND colid IN (SELECT colid FROM syscolumns WHERE id=a.id

AND name=a.name)))) THEN ” ELSE ” END,

类型= b.name,

字节数= a.length,

长度 = COLUMNPROPERTY(a.id,a.name,’Precision’),

小数 = CASE ISNULL(COLUMNPROPERTY(a.id,a.name,’Scale’),0) WHEN 0 THEN ”
ELSE CAST(COLUMNPROPERTY(a.id,a.name,’Scale’) AS VARCHAR) END,