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

SQLѧϰ֮Á¬½Ó·û£¬ÊýÖµÔËË㣬º¯Êý

create table bookitem
(
bookname varchar(80) not null,
book_price Decimal(5,2) not null,
quantity int not null
)
 
insert into bookitem values('Image Processing',34.95,8)
insert into bookitem values('Signal Processing',51.75,6)
insert into bookitem values('Singal And System',48.5,10)
insert into bookitem values('Digital Signal Processing',45.0,12)
insert into bookitem values('The Logic Circuit',28.65,10)
insert into bookitem values('SQL Techniques',65.50,10)
insert into bookitem values('A Firest Course in Database Systems',52.80,9)
 
 
-------Teacher
create table teacher
(
TNO int not null,
TNAME char(10) not null,
CNO int not null,
SAL int,
DNAME char(10) not null,
TSEX char(2) not null,
AGE int not null
)
 
insert into teacher values(1,'Íõ¾ü',4,800,'Êýѧ','ÄÐ',32)
insert into teacher values(2,'ÀîÍ®',5,1200,'ÉúÎï','Å®',54)
insert into teacher values(3,'ÍõÓÀ¾ü',1,900,'¼ÆËã»ú','ÄÐ',40)
insert into teacher values(4,'ÁõС¾²',2,1200,'¼ÆËã»ú','Å®',39)
insert into teacher values(5,'¸ßΰ',8,2100,'µç×Ó¹¤³Ì','ÄÐ',39)
insert into teacher values(6,'Àîΰ',7,1200,'»úе¹¤³Ì','ÄÐ',29)
insert into teacher values(3,'ÍõÓÀ¾ü',1,900,'¼ÆËã»ú','ÄÐ',40)
 
 
---Course
create table course
(
CNO int not null,
CNAME char(30) not null,
CTIME int not null,
SCOUNT int not null,
CTEST smalldatetime not null
)
 
insert into course values(4,'Ó¦ÓÃÊýѧ»ù´¡',48,120,2006-7-10)
insert into course values(5,'ÉúÎ﹤³Ì¸ÅÂÛ',32,80,2006-7-8)
insert into course values(1,'¼ÆËã»úÈí¼þ»ù´¡',32,70,2006-7-8)
insert into course values(2,'¼ÆËã»úÓ²¼þ»ù´¡',28,90,2006-7-10)
insert into course values(8,'Ä£Äâµç·Éè¼Æ',48,120,2006-7-10)
insert into course values(3,'ÉúÎﻯѧ',32,40,2006-7-2)
insert into course values(9,'Êý¾Ý¿âÉè¼Æ',16,80,2006-7-1)
insert into course values(6,'Éè¼ÆÀíÂÛ',28,45,2006-6-30)
 
 
create table student
(
SNO char(4) not null,
sname char(10) not null,
dname char(10) not null,
sex char(2),
CNO i


Ïà¹ØÎĵµ£º

¹ØÓÚдSQLÓï¾ä

Çë½Ì¸ßÊÖÒ»¸öÎÊÌ⣬ÎÊÌâÃèÊöÈçÏ£º
A±íÊǸ÷¸öµ¥Î»µÄÃû³Æ±í ×Ö¶ÎΪ org_id ºÍ org_name
B±íÊÇÕâЩµ¥Î»µÄµç»°ºÅÂë±í ×Ö¶ÎΪ org_idºÍ tel
A±í B±í¹ØÁª·½Ê½ÎªA.ORG_ID=B.ORG_ID 
org_idÊǸ÷¸öµ¥Î»µÄ´úÂë
org_nameÊǸ÷¸öµ¥Î»µÄÃû³Æ
telÊǸ÷¸öµ¥Î»µÄµç»°ºÅÂë
±¾ÈËÏÖÔÚÏëÕë¶Ôÿ¸öµ¥Î»£¨Ã¿Ìõorg_id£©È¡Æä10¸öºÅÂë
Ç ......

SQL ѧϰ±Ê¼ÇÖ®Ë÷Òý

----use pubs-sales
-----´´½¨Ë÷Òý
create index index_name
on authors(au_lname)
--´´½¨Ë÷Òýºó±íÖÐËùÓеÄÊý¾Ý¸ú֮ǰûÓÐÇø±ð
select * from authors
--µ¥¶À²éË÷ÒýÁÐ
select au_lname from authors
--Ç¿ÖÆʹÓ÷Ǵؼ¯Ë÷Òý
select * from  authors with(index(index_name))
--¶à×ֶηǴؼ¯Ë÷Òý
create inde ......

ÇÉÓÃSQLÖеÄWITH£¨Ê÷ÐͽṹÊý¾ÝµÄ²éѯ£©

Èç¹û±íÖдæ·ÅµÄÊý¾ÝÊÇÊ÷Ðνṹ£¬µ±ÖªµÀijһ¸ö½ÚµãµÄֵʱ£¬Í¬Ê±ÏëÈ¡µÃËüËùÓÐ×Ó½ÚµãµÄÊý¾Ý¡£
±í½á¹¹£º
        
         
 ±íÖдæ·ÅµÄÊDz¿ÃÅ×éÖ¯½á¹¹£¬ BMN_CD²¿ÃÅ£¬SSK_KAISO_LVÊǽײ㣬BMN_MKJ²¿ÃÅÃû³Æ£¬JOI_KAISO_LVÉÏ ......

SQLÖ´ÐÐ˳Ðò

Ò»¡¢sqlÓï¾äµÄÖ´Ðв½Ö裺
1£©Óï·¨·ÖÎö£¬·ÖÎöÓï¾äµÄÓï·¨ÊÇ·ñ·ûºÏ¹æ·¶£¬ºâÁ¿Óï¾äÖи÷±í´ïʽµÄÒâÒå¡£
2£© ÓïÒå·ÖÎö£¬¼ì²éÓï¾äÖÐÉæ¼°µÄËùÓÐÊý¾Ý¿â¶ÔÏóÊÇ·ñ´æÔÚ£¬ÇÒÓû§ÓÐÏàÓ¦µÄȨÏÞ¡£
3£©ÊÓͼת»»£¬½«Éæ¼°ÊÓͼµÄ²éѯÓï¾äת»»ÎªÏàÓ¦µÄ¶Ô»ù±í²éѯÓï¾ä¡£
4£©±í´ïʽת»»£¬ ½«¸´Ô SQL ±í´ïʽת»»Îª½Ï¼òµ¥µÄµÈЧÁ¬½Ó±í´ïʽ ......

ÈçºÎ²éѯSQL Server±¸·Ý»¹Ô­ÀúÊ·¼Ç¼

SQL ServerÔÚmsdbÊý¾ÝÖÐά»¤ÁËһϵÁÐ±í£¬ÓÃÀ´´æ´¢Ö´ÐÐËùÓб¸·ÝºÍ»¹Ô­µÄϸ½ÚÐÅÏ¢¡£¼´Ê¹ÄãÕýÔÚʹÓõÚÈý·½µÄ±¸·ÝÓ¦ÓóÌÐò£¬Ö»ÒªÕâ¸öÓ¦ÓóÌÐòʹÓÃSQL ServerµÄÐéÄâÉ豸½Ó¿Ú(Virtual Device Interface---VDI)À´Ö´Ðб¸·ÝºÍ»¹Ô­Ö´ÐУ¬ÄÇôִÐÐϸ½ÚÒÀÈ»±»´æ´¢ÔÚÕâһϵÁбíÖС£
´æ´¢Ï¸½ÚµÄ±í°üÀ¨£º
backupset 
backupfile&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ