--sql中判断数据库是否存在
if exists(select 1 from master..sysdatabases where name='book')
print 'DataBase existed'
else
print 'Database not existed'
go
--sql中创建数据库
--create database book
go
--sql中利用存储过程查看用户
--exec sp_helpuser
go
--利用存储过程删除登录账号
--exec sp_droplogin'sa'
--sql中判断表的存在
IF Exists(Select 1 From sysObjects Where Name ='表名' And Type In ('S','U'))
Print 'Exists Table'
Else
Print 'Not Exists Table'
go
--sql中删除存在的表
use book
go
if object_id('a','U') is not null
drop table test
go
/*
注:a 是一个表,U代表是数据表类型
类似于U的类型代码,如下所示
对象类型:
AF = 聚合函数 (CLR)
C = CHECK 约束
D = DEFAULT(约束或独立)
F = FOREIGN KEY 约束
PK = PRIMARY KEY 约束
P = SQL 存储过程
PC = 程序集 (CLR) 存储过程
FN = SQL 标量函数
FS = 程序集 (CLR) 标量函数
FT = 程序集 (CLR) 表值函数
R = 规则(旧式,独立)
RF = 复制筛选过程
SN = 同义词
SQ = <strong class="kgb" οnmοuseοver="isShowAds = false;isShowAds2 = false;isShowGg = true;
InTextAds_GgLayer="_u670D_u52A1";KeyGate_ads.ShowGgAds(this,"_u670D_u52A1",event)"
style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; font-weight: normal;
border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; margin: 0px; cursor: hand;
color: #0000ff; padding-top: 0px; border-right-width: 0px;
text-decoration: underline" οnclick="javascript:window.open("http://www.google.com/aclk?sa=L&ai=Bh2rlOAWHR56sBozu6AOroqCAC5_q_jCXvsOWA_iU2JQFwKkHEAIYAiCvmqoJKAM4AVDrnYft_f____8BYJ3h24HQBaoBCjEwMDAwMTYwMDLIAQHIAo-anALZAwUzhILJ-9To&num=2&q=http://www2.tek.com/cnweb/products/oscilloscopes/%3FWT.srch%3D1%26WT.mc_id%3Dppc,ggl,scope_aw_ch_cn_scope,k171E,s,766361139%26&sig=AGiWqtxyWRPsXCeA4J63cbgSQs3krP7s8Q");
GgKwClickStat("服务","www.tektronix.com.cn","afs","1000016002");" οnmοuseοut="isShowGg = false;InTextAds_GgLayer="_u670D_u52A1"">服务队列
TA = 程序集 (CLR) DML <strong class="kgb" οnmοuseοver="isShowAds = false;isShowAds2 = false;
isShowGg = true;InTextAds_GgLayer="_u89E6_u53D1_u5668";
KeyGate_ads.ShowGgAds(this,"_u89E6_u53D1_u5668",event)" style="border-top-width: 0px;
padding-right: 0px; padding-left: 0px; font-weight: normal; border-left-width: 0px;
border-bottom-width: 0px; padding-bottom: 0px; margin: 0px; cursor: hand; color: #0000ff;
padding-top: 0px; border-right-width: 0px;
text-decoration: underline" οnclick="javascript:window.open("http://www.google.com/aclk?sa=l&ai=BQIoCOAWHR56sBozu6AOroqCAC5iBlTOIz87RBPDWtnnAmgwQARgBIK-aqgkoAzABOAFQ7tXJy_7_____AWCd4duB0AWgAaqp9v4DqgEKMTAwMDAxNjAwMsgBAcgC6MOOAdkDBTOEgsn71OjgAxA&num=1&q=http://toolbar.google.com/T4/intl/zh-CN/%3Futm_campaign%3DzhCN%26utm_source%3DzhCN-ha-ww-google%26utm_medium%3Dha%26utm_term%3D%25E5%25B7%25A5%25E5%2585%25B7%26tbbrand%3DGZAZ&sig=AGiWqtzKjiNgl3U7aRUdC4tjyZq0F7XBBQ");
GgKwClickStat("触发器","toolbar.google.com/zh-CN","afs","1000016002");" οnmοuseοut="isShowGg = false;InTextAds_GgLayer="_u89E6_u53D1_u5668"">触发器
TR = SQL DML 触发器
IF = SQL 内联表值函数
TF = SQL 表值函数
U = 表(用户定义类型)
UQ = UNIQUE 约束
V = 视图
X = 扩展存储过程
IT = 内部表
*/