资源描述:
《数据库系统及应用实验与课程设计指导SQL2008》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、select*fromsys.serverswhereserver_id=0select*fromsys.databasesselect*fromsys.filegroupsselect*fromsys.master_filesselect*fromsys.database_filesselect*fromsys.data_spacescreatetabletest(idintnotnull,namechar(100)null,constraintpk_testprimarykeyclustered(
2、idasc))createnonclusteredindexix_testontest(name)select*fromsys.objectswheretype_desc='user_table'andname='test'select*fromsys.objectswheretype_desc='user_table'andname='test'orparent_object_idin(selectobject_idfromsys.objectswheretype_desc='user_table'
3、andname='test')select*fromsys.columnswhereobject_id='12'select*fromsys.indexeswhereobject_id='12325345'select*fromsys.partitionswhereobject_id='12325345'select*fromsys.allocation_unitsselect*fromsys.allocation_unitsu,sys.partitionspwhereu.typein(1,3)and
4、u.container_id=p.hobt_idandp.object_id='33'unionallselect*fromsys.allocation_unitsu,sys.partitionspwhereu.type=2andu.container_id=p.partition_idandp.object_id='33'select*fromsys.dm_db_partition_statswhereobject_id='33'select*fromsys.index_columnswhereob
5、ject_id='11'select*fromsys.database_principalsselect*fromsys.types--数据库的创建createdatabaseeduconprimary(name=student_data,filename='C:ProgramFilesMicrosoftSQLServerMSSQL.1MSSQLDATAstudent_data.mdf',size=10MB,maxsize=50MB,filegrowth=1MB)logon(name=st
6、udent_log,filename='C:ProgramFilesMicrosoftSQLServerMSSQL.1MSSQLDATAstudent_log.ldf',size=2MB,maxsize=5MB,filegrowth=1%)--创建测试数据useeducgocreatetablestudent(svarchar(10),snamenvarchar(10),sagedatetime,ssexnvarchar(10))insertintostudentvalues('01',N
7、'赵雷','1990-01-01',N'男')insertintostudentvalues('02',N'钱电','1990-12-21',N'男')insertintostudentvalues('03',N'孙风','1990-05-20',N'男')insertintostudentvalues('04',N'李云','1990-08-06',N'男')insertintostudentvalues('05',N'周梅','1991-12-01',N'女')insertintostudentv
8、alues('06',N'吴兰','1992-03-01',N'女')insertintostudentvalues('07',N'郑竹','1989-07-01',N'女')insertintostudentvalues('08',N'王菊','1990-01-20',N'女')createtablecourse(cvarchar(10),cnamenvarchar(10),tvarchar(10))insertintocoursevalues('01