Transact-SQL????????????
???????????? ???????[ 2013/8/8 14:59:11 ] ????????
?????????????????????????(database)
/*?????????*/
create database USER_INFO
/*
ON?????????????????????????????????
LOG ON??????????????????????????????塣
FILENAME????????????????洢???????????????
%Program Files%Microsoft SQLServerMSSQLData
*/
ON
(
NAME = USER_INFO_Data??
FILENAME ='d:My Documents
SQL Server 2000-DBUSER_INFO.mdf'
)
LOG ON
(
NAME = USER_INFO_log??
FILENAME ='d:My Documents
SQL Server 2000-DBUSER_INFO.ldf'
)
/*????????????*/
sp_renamedb 'USER_INFO'??'ExamSystem';
/*????????*/
drop database USER_INFO
??????????????????????????(table)
/*?????????*/
create table DEPARTMENT
(DEPT_ID int NOT NULL??
DEPT_NAME varchar(20) NOT NULL??
PARENT_DEPT_ID int default NULL??
primary key (DEPT_ID)
)
/*????????????*/
create table USER_INFO
(
/*????? ???????? ?????? */
USER_NO CHAR(6) NOT NULL??
NAME VARCHAR(20) NOT NULL??
DEPT_ID INTEGER NOT NULL??
JOB_ID INTEGER NOT NULL??
GRADE TINYINT NOT NULL??
STATE TINYINT NOT NULL
primary key (USER_NO)/*????????*/
foreign key (DEPT_ID)/*??????*/
references DEPARTMENT
on delete set null
)
/*references DEPARTMENT on delete[restrict|cascade|set null]*/
1.restrict:???????DEPTMENT?е??DEPT_ID????USER_INFO???????????????DEPTMENT?е?DEPT_ID=USER_INFO.DEPT_ID?????????
2.cascade: ???????DEPTMENT?е??DEPT_ID????USER_INFO??????????????DEPTMENT?е?DEPT_ID=USER_INFO.DEPT_ID????????????USER_INFO?е???????????????
3.set null: ???????DEPTMENT?е??DEPT_ID????USER_INFO??????????????DEPTMENT?е?DEPT_ID=USER_INFO.DEPT_ID????????????USER_INFO?е?????????DEPT_ID????????null??
/*????????????*/
sp_rename 'USER_INFO'??'USER_DETAILS';
/*?????*/
drop table USER_INFO
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11