.net 0809 notes

Time really flies, strengthen the foundation course is over, now the database course.

The establishment of the database:

create database MySchool
on primary
(
name='MySchool',
fileName='D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MySchool.mdf',
size=10MB,
filegrowth=1MB,
maxsize=100MB
)
log on
(
name='MySchool_log',
fileName='D:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\MySchool_log.ldf',
size=3MB,
filegrowth=10%

)

The establishment of the table:

create table Test(id int identity(1,1) primary key,name nvarchar(10) not null,age int not null,gender char(2) not null);

Delete table:

drop table Test;

Insert data:

insert into Test(name,age,gender)values('Xiao Zhao ', 99,' women');

Query data:

select name from Test where gender ='Male';

Revised data:

update Test set age=age+5 where gender='Female';

Delete data:

delete from Test where age>50;

delete from Test;Test and truncate table; the difference: the 1.truncate statement is very efficient 2.truncate statements automatically number reset to default values in the table


Below is the classification and different data types

Classification

Notes and instructions

Type

Explain

Binary data types

Store non sub symbols and text data

Image

Can be used to store the image

Text data type

Combination of character data including any letters, symbols or numbers of characters

Char,8000

Non Unicode character data of fixed length. Fixed length strings to strings of variable length, efficiency is higher, when the data length fixed preferred fixed length, eliminates the length calculation process, improve the efficiency of

Varchar,8000

Variable length of non Unicode data

Nchar,4000

The Unicode data of fixed length

Nvarchar,4000

Variable length Unicode data

Text

varchar(max)

The storage of long text information (pointers,2G)

varchar(max), Large string types can be saved very many characters, but for this type of data DBMS often save them to a separate space, which leads to the preservation of data and the loading speed is slow, so unless necessary, otherwise do not use.

Ntext

nvarchar(max)

Nvarchar(max)Instead of

Date and time

Date and time input in single quotation marks

Datetime

Date and time

Digital data

The data contain only numbers, including positive, negative and fractional

int

smallint

Integer

float

real

Digital

Currency data type

For decimal currency values, money and smallmoney data types are accurate to monetary units they represent 1/10000.


Money

The Bit data type

Said yes / no data

Bit

Store the Boolean data type

Posted by Z at November 19, 2013 - 7:28 AM