n CREATE DATABASE CREATE DATABASE newtest n DROP
数据库的建立与删除 n 建立数据库 – CREATE DATABASE <数据库名> [其他参数]; – CREATE DATABASE newtest; n 数据库的删除 – DROP DATABASE <数据库名>; – DROP DATABASE newtest;
SQL Server中的数据库创建 CREATE DATABASE database_name [ ON [ < filespec > [ , . . . n ] ] [ , < filegroup > [ , . . . n ] ] ] [ LOG ON { < filespec > [ , . . . n ] } ] [ COLLATE collation_name ] [ FOR LOAD | FOR ATTACH ] < filespec > : : = [ PRIMARY ] ( [ NAME = logical_file_name , ] FILENAME = 'os_file_name' [ , SIZE = size ] [ , MAXSIZE = { max_size | UNLIMITED } ] [ , FILEGROWTH = growth_increment ] ) [ , . . . n ] < filegroup > : : = FILEGROUP filegroup_name < filespec > [ , . . . n ]
简单示例 例: CREATE TABLE Student n (Sno CHAR(5) NOT NULL UNIQUE, Sname CHAR(20), Ssex CHAR(1), Sage INT, Sdept CHAR(15)); v 定义及约束条件存于数据字典中
示例 Create TABLE SC ( SNO char (7) not null, CNO char (4) not null, G smallint not null default 0, Primary key (SNO, CNO), Foreign key student_no (SNO) References S on delete CASCADE on update SETNULL, Foreign key course_no (CNO) References C on delete SETNULL on update RESTRICT, Unique (SNO, CNO), Check (G>=0 and G<=100) );
- Slides: 16