查询某个数据库中的所有表 :
select * from sysobjects where xtype='u';
查询某个表的表结构:
select col.[name] as '字段名',
col.[length] as '长度', type.[name] as '类型', pro.value as '描述' from syscolumns as col left join Systypes as type on col.xtype=type.xtype left join SysProperties as pro on col.id=pro.id and col.colid=pro.smallid where col.id=(select id from Sysobjects where name='要查询的表名'); 随机选择记录:
select newid();
随机读取若干条记录:[ ------>n表示要取出的数据行数]
sqlserver------>: select top n * from 表名 order by newid();
mysql--------->: select * from 表名 order by rand() limit n;
|
|
来自: xiagirl333 > 《数据库》