使用t-sql语句在sqlserver里建库建表建约束(Use the T-SQL statement to build the database in sqlserver and build a constraint).docVIP

  • 8
  • 0
  • 约 10页
  • 2017-07-24 发布于河南
  • 举报

使用t-sql语句在sqlserver里建库建表建约束(Use the T-SQL statement to build the database in sqlserver and build a constraint).doc

使用t-sql语句在sqlserver里建库建表建约束(Use the T-SQL statement to build the database in sqlserver and build a constraint)

使用t-sql语句在sqlserver里建库建表建约束(Use the T-SQL statement to build the database in sqlserver and build a constraint) - use xp_cmdshell to use the DOS command Exec, sp_configure,show, advanced, options, 1 Go RECONFIGURE Go Exec sp_configurexp_cmdshell, 1 Go RECONFIGURE Go - create a folder in the D disk project Exec xp_cmdshellmkdir D:\project Go ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------------------------ -- database building section -- whether the query is known as the database for MySchool Use master - sets the current database to master to access the sysdatabases table Go Delete him if you have a MYSCHOOL database If, exists (select * from, sysdatabases, where, name =MySchool) Drop database MySchool The new database named MySchool Create database MySchool On primary ( Specific description: main data file Name =MySchool_data1, Filename =D:\project\MySchool1_data.mdf, Size = 10, Maxsize = unlimited, Filegrowth = 20% ) Log on (- log file 1 describes Name =MySchool_log1, Filename =D:\project\MySchool1_log.ldf, Size = 3, Maxsize = 20, Filegrowth = 1 ) Go ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------------------------ Create table parts Use MySchool -- a new table in MySchool Go Delete if it exists If exists (select * from, sysobjects, where, name, =Subject) Drop table Subject Create table Subject -- a new table ( SubjectNo, int, identity (1,1), not, null - - course number SubjectName nvarchar (50) not null - - course name ClassHour int, - class hour GradeID int - age number ) Go Use MySchool -- a new table in MySchool GO If exists (select * from, sysobjects, where, name, =Result) Drop table Result Create table Result ( StudentNo, int, not, null -- student number Subj

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档