资源描述:
《sql server基础查询练习(附答案)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、--创建数据库USE[master]GOCREATEDATABASE[test]ONPRIMARY(NAME=N'test',FILENAME=N'D:SQLDataBasetest.mdf',SIZE=3072KB,MAXSIZE=UNLIMITED,FILEGROWTH=1024KB)LOGON(NAME=N'test_log',FILENAME=N'D:SQLDataBasetest_log.ldf',SIZE=1024KB,MAXSIZE=2048GB,FILEGROWTH=10%)GO
2、ALTERDATABASE[test]SETCOMPATIBILITY_LEVEL=90GOIF(1=FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))beginEXEC[test].[dbo].[sp_fulltext_database]@action='enable'endGOALTERDATABASE[test]SETANSI_NULL_DEFAULTOFFGOALTERDATABASE[test]SETANSI_NULLSOFFGOALTERDATABAS
3、E[test]SETANSI_PADDINGOFFGOALTERDATABASE[test]SETANSI_WARNINGSOFFGOALTERDATABASE[test]SETARITHABORTOFFGOALTERDATABASE[test]SETAUTO_CLOSEOFFGOALTERDATABASE[test]SETAUTO_CREATE_STATISTICSONGOALTERDATABASE[test]SETAUTO_SHRINKOFFGOALTERDATABASE[test]SETAUTO_UP
4、DATE_STATISTICSONGOALTERDATABASE[test]SETCURSOR_CLOSE_ON_COMMITOFFGOALTERDATABASE[test]SETCURSOR_DEFAULTGLOBALGOALTERDATABASE[test]SETCONCAT_NULL_YIELDS_NULLOFFGOALTERDATABASE[test]SETNUMERIC_ROUNDABORTOFFGOALTERDATABASE[test]SETQUOTED_IDENTIFIEROFFGOALTER
5、DATABASE[test]SETRECURSIVE_TRIGGERSOFFGOALTERDATABASE[test]SETDISABLE_BROKERGOALTERDATABASE[test]SETAUTO_UPDATE_STATISTICS_ASYNCOFFGOALTERDATABASE[test]SETDATE_CORRELATION_OPTIMIZATIONOFFGOALTERDATABASE[test]SETTRUSTWORTHYOFFGOALTERDATABASE[test]SETALLOW_S
6、NAPSHOT_ISOLATIONOFFGOALTERDATABASE[test]SETPARAMETERIZATIONSIMPLEGOALTERDATABASE[test]SETREAD_COMMITTED_SNAPSHOTOFFGOALTERDATABASE[test]SETREAD_WRITEGOALTERDATABASE[test]SETRECOVERYSIMPLEGOALTERDATABASE[test]SETMULTI_USERGOALTERDATABASE[test]SETPAGE_VERIF
7、YCHECKSUMGOALTERDATABASE[test]SETDB_CHAININGOFFGO--创建表USEtestCREATETABLEemp(EMPNONUMERIC(5,0)NOTNULL,ENAMENVARCHAR(10),JOBNVARCHAR(9),MGRNUMERIC(5,0),HIREDATEDATETIME,SALNUMERIC(7,2),COMMNUMERIC(7,2),DEPTNONUMERIC(2,0),)CREATETABLEdept(DEPTNONUMERIC(2),DNA
8、MENVARCHAR(14),LOCNVARCHAR(13),)--插入数据INSERTINTOEMPVALUES(7369,'SMITH','CLERK',7902,'2000-12-17',800,NULL,20);INSERTINTOEMPVALUES(7499,'allen','SALESMAN',7698,'2001-2-20',1600,300,30);INSERTINTOEMPVALUES(7521