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

SQL Server

²éѯ card µÄ¼Ç¼ΪÁ½´ÎÒÔÉ쵀 card£¬¼Ç¼Êý:
select count(card), card from TableName group by card having count(card) > 1
¼¶Áª¸üУ¬¼¶ÁªÉ¾³ý:
ColumnName type not null constraint FK_Name foreign key(ColumnName) references PrimaryTable(ColumnName) on update/delete cascade
×Ô¶¯¼ÆËãÁÐ:
create table TableName
(
 ID int,
 Price decimal(10,2) not null,
 Number int not null,
 Total as Price * number  -- Total ²»´æ´¢Öµ¡£
)
insert into TableName values(1, 100, 123)
insert into TableName values(1, 100, 123)
insert into TableName values(2, 200, 456)
insert into TableName values(2, 200, 456)
select ID, Total=SUM(Total) from TableName where ID = 1 group by ID
ÐÞ¸ÄÏÖÓÐÉÌÆ·ÊýÁ¿:
begin
begin tran
declare @ForeignError int, @PrimaryError int
insert into ForeignTable values(@ID, @Number)
select @ForeignError=@@Error              -- @@Error: ·µ»ØÖ´ÐеÄÉÏÒ»¸ö Transact-SQL Óï¾äµÄ´íÎóºÅ¡£
update PrimaryTable set Number=Number ± @Number where ID=@ID --½ø»õʱÓüӺš£
select @PrimaryError=@@Error
if (@ForeignError = 0 and @PrimaryError = 0)
 commit tran
else
 rollback tran
end
begin
begin tran
declare @ForeignError int, @PrimaryError int, @NewNumber int
update ForeignTable set Number=@Number, @NewNumber=@Number - Number where ID=@ID
select @ForeignError=@@Error
update PrimaryTable set Number=Number ± @NewNumber where ID=@ID --½ø»õʱÓüӺš£
select @PrimaryError=@@Error
if (@ForeignError = 0 and @PrimaryError = 0)
 commit tran
else
 rollback tran
end 


Ïà¹ØÎĵµ£º

SQL Óα꣨1£©

¹ØϵÊý¾Ý¿âÖеIJÙ×÷»á¶ÔÕû¸öÐм¯Æð×÷Óá£ÓÉ SELECT Óï¾ä·µ»ØµÄÐм¯°üÀ¨Âú×ã¸ÃÓï¾äµÄ WHERE ×Ó¾äÖÐÌõ¼þµÄËùÓÐÐС£ÕâÖÖÓÉÓï¾ä·µ»ØµÄÍêÕûÐм¯³ÆΪ½á¹û¼¯¡£Ó¦ÓóÌÐò£¬ÌرðÊǽ»»¥Ê½Áª»úÓ¦ÓóÌÐò£¬²¢²»×ÜÄܽ«Õû¸ö½á¹û¼¯×÷Ϊһ¸öµ¥ÔªÀ´ÓÐЧµØ´¦Àí¡£ÕâЩӦÓóÌÐòÐèÒªÒ»ÖÖ»úÖÆÒÔ±ãÿ´Î´¦ÀíÒ»ÐлòÒ»²¿·ÖÐС£Óαê¾ÍÊÇÌṩÕâÖÖ»úÖƵĶԽ ......

Oracle SQL*LoaderÊý¾Ý×°ÔØ

SQL*Loader ÓÃÓÚ½«´óÁ¿Êý¾Ý×°ÈëÊý¾Ý¿â¡£
¢Å¡¢¶¨¿íÊý¾Ý
´´½¨Êý¾ÝÎļþcontrol.txt£º
aaa,bbb
ccc,ddd
eee,fff
´´½¨¿ØÖÆÎļþcontrol.ctl£º
load data
infile 'c:\loader.txt'
append
into table tester.mm(
m1 position(1:3) char,
m2 position(5:7) char)
ÅúÁ¿¼ÓÔØÊý¾Ý£º
sqlldr tester/test control=c:\loade ......

SQLÀúÊ·ÓëʵÏÖ

 
ÔÚ20ÊÀ¼Í70Äê´ú³õÆÚ£¬IBMÑо¿Ô±E. F. Codd²©Ê¿¿ª´´ÐÔµØÑо¿¿ª·¢Á˹ØϵÊý¾ÝÄ£ÐͲúÆ·SEQUEL£¬¼´½á¹¹»¯Ó¢Óï²éѯÓïÑÔ£¨Structured English Query Language£©¡£SEQUEL×îÖÕ±ä³ÉÁËSQL£¬»ò½á¹¹»¯²éѯÓïÑÔ£¨Structured Query Language£¬SQL£©¡£
IBM¼°ÆäËû¹ØϵÊý¾Ý¿âµÄ¿ª·¢³§É̶¼Ï£ÍûÓÐÒ»Ì×ÄÜ·ÃÎʲ¢²Ù×ݹØϵÊý¾Ý¿âµÄ±ê×¼»¯·½ ......

sql server 2005°²×°¹ý³ÌÖÐÓöµ½µÄһЩÎÊÌâ

°²×°µÄ×é¼þºÍ°æ±¾µÄÐÅÏ¢
Microsoft SQL Server Management Studio      9.00.1399.00
Microsoft Analysis Services ¿Í»§¶Ë¹¤¾ß      2005.090.1399.00
Microsoft Êý¾Ý·ÃÎÊ×é¼þ (MDAC)      6.1.7600.16385 (win7_rtm.090713 ......

SQLÓï¾äÓÅ»¯

 SQLÓï¾äÓÅ»¯£º
(1)¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐëдÔÚWHERE×Ó¾äµÄĩβ.
(2)SELECT×Ó¾äÖбÜÃâʹÓà ‘ * ‘
(3)¼õÉÙ·ÃÎÊÊý¾Ý¿âµÄ´ÎÊý
·½·¨3 (¸ßЧ)?
SELECT A.EMP_NAME , A.SALARY , A.GRADE,
B.EMP_NAME , B.SALARY , B.GRADE
from EMP A,EMP B
WHERE A.EMP_NO = 342
AND B.EMP_NO = 291;
( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ