标签:
sql server 2005:
1 --SQL SERVER 2005 生成代码需要知道的SQL语句 2 use LibrarySystem 3 --查询当前数据库所有表和其的主键字段,字段类型,长度,是否为空值 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.name 5 --获取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‘;
标签:
原文地址:http://www.cnblogs.com/geovindu/p/4355604.html