Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL SERVERÓï·¨

1.´´½¨±í
(1)ÓÃCreate Table ÃüÁî´´½¨±í
Óï·¨:
Create Table tabl_name
({
}column_name As computed_column_expression
}
}[£¬...n]
)
[On {fiegroup | Default}]
[Textimage_On {fiegroup | Default}]
Àý×Ó:
´ò¿ªcustÊý¾Ý¿â£¬´´½¨Ò»¸ö±í£¬¸Ã±í°üº¬ÁËѧÉúµÄÓйØÐÅÏ¢£¬¼´ÓÐѧºÅ¡¢ÐÕÃû¡¢ÐԱ𡢳öÉúÈÕÆÚ¡¢¼®¹á¡¢ÁªÏµµç»°¡¢×¡Ö·ºÍ±¸×¢ÐÅÏ¢¡£
Use cust
Create Table students
(
number int not null£¬
name varchar(10) not null£¬
sex char(2) null£¬
birthday datetime null£¬
hometown varchar(30) null£¬
telphone_no varchar(12) null£¬
address varchar(30) null£¬
others varchar(50) null
)
ÔÚÕâ¸ö±íÖÐnumber±íʾѧÉú´úºÅ£¬Êý¾ÝÀàÐÍΪint£¬²»ÔÊÐíΪ¿Õ;name±íʾѧÉúÐÕÃû£¬Êý¾ÝÀàÐÍΪvarchar£¬³¤¶ÈΪ10£¬²»ÔÊÐíΪ¿Õ;sex±íʾѧÉúµÄÐÔ±ð£¬Êý¾ÝÀàÐÍΪchar£¬³¤¶ÈΪ2£¬ÔÊÐíΪ¿Õ;birthday±íʾѧÉúµÄ³öÉúÈÕÆÚ£¬Êý¾ÝÀàÐÍΪdatetime£¬ÔÊÐíΪ¿Õ;hometown±íʾѧÉúµÄ¼®¹á£¬Êý¾ÝÀàÐÍΪvarchar£¬³¤¶ÈΪ30£¬ÔÊÐíΪ¿Õ;telephone_no±íʾѧÉúµÄÁªÏµµçÄÔ£¬Êý¾ÝÀàÐÍΪvarchar£¬³¤¶ÈΪ12£¬ÔÊÐíΪ¿Õ;address±íʾѧÉúµÄסַ£¬Êý¾ÝÀàÐÍΪvarchar£¬³¤¶ÈΪ30£¬ÔÊÐíΪ¿Õ;others±íʾѧÉúµÄ±¸×¢ÐÅÏ¢£¬³¤¶ÈΪ50£¬ÔÊÐíΪ¿Õ¡£
2.Ð޸ıíµÄ½á¹¹
(1)ʹÓÃT-SQLÓï¾äÔö¼ÓºÍɾ³ýÒ»¸öÐÂÁÐ
Óï·¨:
Alter Table table
{
ADO
{[]
|colun_name As computed_column_expression
|[]
}[£¬...n]
|Drop
{Column column
}[£¬...n]
}
Àý×Ó:´ò¿ªcustÊý¾Ý¿â£¬ÐÞ¸ÄÆäÖеıístudentsµÄ½á¹¹£¬Ôö¼ÓÒ»¸öÐÂ×ֶΣ¬×Ö¶ÎÃûΪying£¬Êý¾ÝÀàÐÍÊÇvarchar£¬³¤¶ÈÊÇ10£¬Ã»ÓÐĬÈÏÖµ£¬³äÐíΪ¿Õ¡£
Use cust
Alter Table students Add ying varchar(10) null
´ò¿ªcustÊý¾Ý¿â£¬ÐÞ¸ÄÆäÖеıístudentsµÄ½á¹¹£¬É¾³ýÒ»¸ö×ֶΣ¬×Ö¶ÎÃûΪying¡£
Use cust
Alter Table students Drop Column ying
3.Ïò±íÖвåÈëÊý¾Ý
(1)Óà Insert Óï¾ä
Óï·¨ÈçÏÂ:
Insert [Into]
{table_name|view_name}[(column_list)]
{Values|values_list|select_statement}
×¢Òâ:ÔÚ²åÈëÊý¾Ýʱ£¬×Ö·ûÊý¾ÝºÍÈÕÆÚÊý¾ÝҪʹÓÃÒýºÅÒýÆðÀ´¡£
Àý×Ó:
Use cust
Insert Into students
Values (11£¬"Ó°×Ó"£¬"ÄÐ"£¬"1999-12-12"£¬"ºþ±±"£¬"83779805"£¬"Î人ÊÐÇÅ¿ÚÇø"£¬"VB°®ºÃÕß")
´ò¿ªcustÊý¾Ý¿â£¬Ïòstudents±íÖвåÈëÊý¾Ý
(2)ÓÃDefault Ñ¡Ïî
ÔÚ²åÈëÊý¾Ýʱ£


Ïà¹ØÎĵµ£º

SQL SERVER×Ö¶ÎÀàÐÍ˵Ã÷

 
bit£º0»ò1µÄÕûÐÍÊý×Ö
int£º´Ó-2^31(-2,147,483,648)µ½2^31(2,147,483,647)µÄÕûÐÍÊý×Ö
smallint£º´Ó-2^15(-32,768)µ½2^15(32,767)µÄÕûÐÍÊý×Ö
tinyint£º´Ó0µ½255µÄÕûÐÍÊý×Ö

decimal£º´Ó-10^38µ½10^38-1µÄ¶¨¾«¶ÈÓëÓÐЧλÊýµÄÊý×Ö
numeric£ºdecimalµÄͬÒå´Ê

money£º´Ó-2^63(-922,337,203,685,477.580 ......

SQLÓï¾ä

1. ˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ£¬Ô´±íÃû£ºa£¬Ð±íÃû£ºb)
SQL: select * into b from a where 1<>1;
        2. ˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý£¬Ô´±íÃû£ºa£¬Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d, e, f from b;
        3. ˵Ã÷£º ......

sql ±¸·ÝºÍɾ³ý

±¸·Ý
DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR,getdate(),120)
set @strPath='hq'+rtrim(left(replace(@strPath,'-',''),8))
set @strPath = 'D:\sqlback\mydb\' + @strPath + '.bak'
BACKUP DATABASE [mydb] TO DISK = @strPath WITH NOFORMAT, NOINIT, NAME = N'mydb-ÍêÕû Êý¾Ý¿â ±¸·Ý', ......

ÃæÊÔ±ØÐëÒªÖªµÀµÄSQLÓï·¨


asc °´ÉýÐòÅÅÁÐ
desc °´½µÐòÅÅÁÐ
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(Create£¬Alter£¬Drop£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(Select£¬Delete£¬Update£¬Insert)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ