sql to modify this statement

: 1. The primary key constraint
conditions for a primary key constraint on a column added, then this column must be met is the partial space
as the primary key constraint: that is, one column of the constraint, the constraint is a (non-empty, not repeated)
The following is the code to to add a primary key column, the column named id, name table emp

Format:
name increased constraint type (column names) alter table name table add constraint constraint
example:
ALTER Table Primary Key EMP add constraint PPP
(ID) ------------------ --------------
2.check constraint:
that the data were a limiting
example, the age column of data must be greater than 20
table (emp) column name (age)
format :
ALTER tABLE name table add constraint constraint constraint types (column names) increased name
examples:
ALTER EMP add constraint XXX Check table (Age> 20 is)
______________________________________________________________________
3.unique constraint:
this constraint is added to the data string is not duplicated constraint type
format:
the ALTER the table table name add constraint constraint name constraint types (column name)
for example can give ename columns add a unique, let the data ename column is not repeated
examples:
the ALTER QWE the table emp add constraint UNIQUE (ename)
--------------------------------
4. default constraint:
the meaning was simply to let the data for this column defaults to a certain data
format:
ALTER tABLE name table add constraint constraint constraint name type default) column name for
example: gongzi emp table column defaults to 10000
ALTER table emp add constraint jfsd default 10000 for gongzi

--------------------------------
5. foreign key constraint:
This bit difficult to understand, in fact, the foreign key reference
because primary key to achieve integrity entities,
foreign keys to achieve the referential integrity,
integrity of the application provides the data referenced must exist!
In fact, a quote,
say, a table name is dept there are two data one is ID one is ENAME
the above mentioned id: indicate the product number
ename: indicates the name of the product
to another table name is emp there are two data, one is ID one is DID
id: means that the user number
did: that the product number purchased
did a column to make emp table to reference dept table id
can use the following method
format:
the ALTER the table table name add constraint constraint name constraint types (column name ) references referenced table names (column names)
examples:
ALTER table EMP the Add constraint name constraint foreign key (did) references dept ( id)

Create a primary key ALTER TABLE STUDENT ADD CONSTRAINT PK_STUDENT PRIMARY KEY CLUSTERED (STUDENTID) ON [PRIMARY] Here polymerization on the primary key index. When the primary key to search faster.

Clustered index just need to find all the data to be retrieved in the beginning and end of the data can be; rather than non-clustered index, you must first be found in the directory found in each of the data corresponding to the page number, and then found out the exact page number in accordance with content. CLUSTERED polymeric index, NONCLUSTERED non-clustered index.

Guess you like

Origin www.cnblogs.com/xiaocongcong888/p/11096153.html