The fourth chapter summarizes the database Video -----

 Field data types

Numeric data types:

Integer data types: bigint, int, smallint, tinyint

decimal和numeric

muney and smalloney

float and real floating-point types

Character data types

Char (10) regardless of whether or not to store characters reach this length is 10 characters occupy space

Varchar (50) of variable length, although the statement 50 space, but he is not necessarily occupy 50 characters.

Text text type

Nchar   

Nvarchar N at the beginning of all the characters unico

Ntext

Date and Time Types

Datetime  和smalldatetime

 It indicates that the difference between two different time and date range, precision are different,

datetime to date 9999-12-31 1753-1-1 range, the accuracy of the time is 3.33 ms.

Smalldatetime 1900-1-1 date range to one minute time precision 2079-12-31

 

Binary type

Binary varbinay, image three data types 

Binary for storing the number of fixed-length binary data,

Varbinary for storing binary data of variable length, the length of storage are both 1-8000

image data for storing image information of specific types

Specific data type

Native data type cursor, sql_variant, table, timestamp, uniqueidentifier, xml of six special purposes.

Temporary tables

Name of the local temporary table # symbol begins with a single number. Only the current user connection is visible. Global temporary table name begins with a double number sign ##, after you create are visible to any user

Create table #test

(id int not null

Name nvarchar(10) null,

Adress nvarchar(50) null

)

You may not see the temporary tables in Object Explorer, but you can use a query to select.

 

The difference between check constraints and rules

check constraint is created in the create table statement indicates that the specified, and rules need to be used as a separate database objects

Only one rule on one, but you can use multiple check constraints

Rules can be applied to multiple columns, can also be applied to user-defined data types, check constraints can only be used in his column

Create a rule: create rule rule name as the value of the expression

Create rule sorce as @value between 0 and 100 to create a rule

Sp_bindrule sorce, 'grade information, scores' constraint bound to a concrete column

Cancellation and delete rules

Rules should be lifted dependence

Futureonly represents the binding is released when the objectname is null type in a user-defined current value, if an error when it is released futureonly

Delete Rule

Drop rule sorce

Unbind

Sp_unbindrule 'achievement information, fraction'

Published 31 original articles · won praise 4 · Views 2292

Guess you like

Origin blog.csdn.net/weixin_44663188/article/details/100636390