[杂]SQL Server 之 Table

. Create schemas

. Select appropriate data types

. Apply column properties to enforce business requirements

. Add computations to a table

. Define storage properties that reduce the amount of space consumed by a row or page

Schemas

In one instance of a database, you could combine the objects into a single database and use schemas to separate groups of objects.

Data Types

Column Properties

Null-ability

Implementing Constraints

. Create a primary key

. Create a foreign key

. Create a unique constraint

. Implement a default constraint

. Apply a check constraint

primary key

Can not by null.

foreign key

Cascading is an extremely bad idea.

Unique Constraints

Keep the row unique.

Default Constraints

SQL Server writes the default value to the column only if the application does not specify the column in the INSERT statement.

你可能感兴趣的:(SQL Server)