sqlÓï¾ä»ù±¾²Ù×÷
1.½¨±íÓï¾ä£ºcreate table
Ó÷¨: create table ±íµÄÃû×Ö (×Ö¶Î1, ×Ö¶Î2,¡£¡£¡£¡£)
¾ÙÀý£ºÀýÈç´´½¨Ò»¸öѧÉú³É¼¨±í£¬°üº¬µÄ×Ö¶ÎÓУ¬Ñ§Éúid£¬ÐÕÃû£¬ÐԱ𣬰༶£¬³É¼¨create table score(
create table score(
sid nvarchar(10) primary key,
sname nvarchar(10) not null,
sex nvarchar(2),
sclass nvarchar(5),
score int,
check(sex in('ÄÐ','Å®'))
);
2.²åÈëÓï¾ä£ºinsert into
Ó÷¨:insert into ±íµÄÃû×Ö (×Ö¶Î1, ×Ö¶Î2,¡£¡£¡£¡£) values (Öµ1£¬Öµ2£¬¡£¡£¡£¡£)
Èç¹û×Ö¶ÎÊDZíÖÐËùÓÐ×Ö¶Î×Ö¶ÎÁбí¿ÉÊ¡È¥£¬Ö±½Óд±íÃû¾ÍÐÐÁË
¾ÙÀý:Íù±íscoreÖвåÈë7ÌõÊý¾Ý
insert into score values('95002','СÀî','ÄÐ','01',82)
insert into score values('95003','СÀö','Å®','01',83)
insert into score values('95004','СÕÔ','ÄÐ','01',67)
insert into score values('95005','СÃÀ','Å®','01',78)
insert into score values('95006','СÌï','ÄÐ','01',88)
insert into score values('95007','СÐì','Å®','01',85)
insert into score values('95008','СÍõ','ÄÐ','01',86)
3.²éѯÓï¾ä£ºselect
Ó÷¨£ºselect ×ֶΠfrom ±íÃû where Ìõ¼þ
×ֶμäÓÃ','·Ö¿ª£¬Í¬ÑùÈç¹ûÑ¡Ôñ±íµÄËùÓÐ×ֶΣ¬¿ÉÓÃͨÅä·û*
¾ÙÀý£ºÊä³öscore±íÖгɼ¨ÔÚ60µ½80µÄͬѧµÄËùÓÐÐÅÏ¢
select * from score where score>=60 and score<=80
Êä³öscore ±íÖгɼ¨Îª85»ò86»ò87µÄѧÉúÐÅÏ¢
select * from score where score=85 or score=86 or score=87
Êä³öscore ±íÖа༶Ϊ95001»òÕßÐÔ±ðΪŮÐÔµÄѧÉúµÄÃû×Ö
select sname from score where sclass='95001' or sec='Å®'
4.ɾ³ýÓï¾ä:delete
Ó÷¨£ºdelete from ±íµÄÃû×Ö where Ìõ¼þ
¾ÙÀý£ºÉ¾³ýscore±íÖзÖÊýµÍÓÚ70·ÖµÄ¼Ç¼
delete from score where score<70
Ïà¹ØÎĵµ£º
ÕªÒª£ºSQL Server 2008ÖÐÌṩÁË9ÖÖ³£ÓõÄÊý¾ÝÍÚ¾òËã·¨£¬ÕâЩËã·¨ÓÃÔÚ²»Í¬Êý¾ÝÍÚ¾òµÄÓ¦Óó¡¾°Ï£¬±¾Îľ͸÷¸öËã·¨Öð¸ö·ÖÎöÌÖÂÛ¡£
±êÇ©£ºÊý¾ÝÍÚ¾òËã·¨ SQL Server 2008
1.¾ö²ßÊ÷Ëã·¨
¾ö²ßÊ÷£¬ÓÖ³ÆÅж¨Ê÷£¬ÊÇÒ»ÖÖÀàËƶþ²æÊ÷»ò¶à²æÊ÷µÄÊ÷½á¹¹¡£¾ö²ßÊ÷ÊÇÓÃÑù±¾µÄÊôÐÔ×÷Ϊ½áµã£¬ÓÃÊôÐÔµÄÈ¡Öµ×÷Ϊ·ÖÖ§£¬Ò²¾ÍÊÇÀàËÆÁ ......
-->Title:Generating test data
-->Author:wufeng4552
-->Date :2009-09-25 09:56:07
if object_id('tb')is not null drop table tb
go
create table tb(ID int,name text)
insert tb select 1,'test'
go
--·½·¨1
select sql_variant_property(ID,'BaseType') from tb
--·½·¨2
select object_name(ID)± ......
Ôʼ±í£º
name course score
-----------------------------------------
ÕÅÈý ÓïÎÄ 80
ÕÅÈý & ......
Êý¾Ý¿â±¸·ÝʵÀý/**
**Êý¾Ý¿â±¸·ÝʵÀý
**Öì¶þ 2004Äê5ÔÂ
**±¸·Ý²ßÂÔ:
**Êý¾Ý¿âÃû:test
**±¸·ÝÎļþµÄ·¾¶e:\backup
**ÿ¸öÐÇÆÚÌìÁ賿1µã×öÒ»´ÎÍêÈ«±¸·Ý,Ϊ±£ÏÕÆð¼û,±¸·Ýµ½Á½¸öͬÑùµÄÍêÈ«±¸·ÝÎļþtest_full_A.bakºÍtest_full_B.bak
**ÿÌì1µã(³ýÁËÐÇÆÚÌì)×öÒ»´Î²îÒ챸·Ý,·Ö±ð±¸·Ýµ½Á½¸öÎļþtest_df_A.bakºÍtest_df ......
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database db ......