您的位置:首页 > 数据库

数据库知识点滴积累

2012-07-02 11:05 337 查看
这些都是工作中遇到的问题,后来通过网上查找积累下来的。

查找一个数据库有多少个表?
select count(*) from sysobjects where xtype='U'

查找一个数据库下所有表的表名
select name from sysobjects where xtype='U'
SELECT name FROM sysobjects WHERE xtype = 'U' Or xtype = 'S'
查找一个表的结构
select * from information_schema.columns where table_name ='表名'
查找非系统数据库
Select name FROM Master.. SysDatabases where dbid>4

停止触发器
alter table 'table_Name' disable trigger all
开始触发器
alter table 'table_Name' enable trigger all

--允许将显式值插入表的标识列中 ON-允许 OFF-不允许
set identity_insert OrderList ON--打开

insert into OrderList(id,ordername,createdate)
values(4520,'set',getdate())

set identity_insert OrderList OFF--关闭

SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
允许将显式值插入表的标识列中

select name from sysobjects where xtype='TR' --所有触发器
select name from sysobjects where xtype='P' --所有存储过程
select name from sysobjects where xtype='V' --所有视图
select name from sysobjects where xtype='U' --所有表
select name from sysobjects where xtype in (N'FN', N'IF', N'TF') --所有的函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: