星空网 > 软件开发 > 数据库

sql: 表结构查询

sql server 2005:

1 --SQL SERVER 2005 生成代码需要知道的SQL语句2 use LibrarySystem3 --查询当前数据库所有表和其的主键字段,字段类型,长度,是否为空值4 SELECT d.name as 'TableName',a.name as 'FieldName',b.name as 'TypeName',a.length as 'Length',a.isnullable as 'IS_NULL' FROM syscolumns a, systypes b,sysobjects d ,INFORMATION_SCHEMA.KEY_COLUMN_USAGE c WHERE a.xtype=b.xusertype and a.id=d.id and d.xtype='U' and c.TABLE_NAME  = d.name and c.COLUMN_NAME=a.name5 --获取BookKindList表结构里面的字段名, 类型,长度6 SELECT c.name  as  FieldName,t.name  as  FieldType,  c.length  as  FieldLength  FROM  SYSCOLUMNS  c  inner  join   systypes  t  on  c.xusertype=t.xusertype  WHERE  c.ID  =  OBJECT_ID('BookKindList')7 --

MySQL 6.7

 1 #数据库MySQL 6.7 2 use sakila; 3 #查询表名 4 show tables; 5 # 6 SELECT TABLE_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='sakila'; 7  8 select column_name from information_schema.columns where table_schema='sakila' and table_name='actor'; 9 #表结构 字段名, 类型,长度10 select * from information_schema.columns where table_schema='sakila' and table_name='actor';

 PostgreSQL 8.4,9.3

1 --查询结构PostgreSQL 8.4,9.32 SELECT * FROM information_schema.columns;3 --查询数据库的建成立的表结构4 SELECT * FROM information_schema.columns where table_catalog='geovindu' and table_schema='public';

 




原标题:sql: 表结构查询

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流