SQL Server database syntax (a)

- creating a database DB_CYIT
Create Database DB_CYIT
the ON
(
name = 'DB_CYIT', - the logical name of the primary file
filename = 'G: \ data \ DB_CYIT.mdf', - file address
size = 5mb, - file size
filegrowth = 2mb - growth master file
)
the lOG the ON
(
name = 'DB_CYIT_log', - log logical name of the primary file
filename = 'G: \ data \ DB_CYIT.ldf', - the primary address log file
size = 5mb, - master file log size
filegrowth = 2mb - master log file growth
)

 

Data integrity (Data Integrity) refers to the accuracy of the data (the Accuracy) and reliability (Reliability)

Entity integrity (Entity Integrity)

PRIMARY KEY (primary key) constraint)

IDENTITY (increment) constraints

UNIQUE (unique) constraints

Domain integrity (Domain Integrity)

CHECK (check) constraint

FOREIGN KEY (foreign key) constraints

DEFAULT (default value) Constraint

NOT NULL (non-null) constraint

Referential integrity (Referential Integrity)

User-defined Integrity (User-defined Integrity)

 


--创建新表
create table Tb_Student
(
StudentNo int identity(1,1) primary key,
StudentName varchar(20) not null,
StudentAge int check(StudentAge<30 and StudentAge>20),
Country varchar(20) default'中国',
StuTime datetime not null,
TuitiON money not null,
)

create table Tb_Student_Course
(
SCNo int identity(1,1) primary key,
StudentNo int references Tb_Student(StudentNo),
CourseName varchar(30) unique not null,
CourseTime int not null,
StuTime datetime not null,
Notes varchar(1000)
)

 

Guess you like

Origin www.cnblogs.com/zxx7777777/p/11365651.html