SQL ΪÖ÷±íµÄıһÌõ¼Ç¼£¬ÔÚÖмä±íÖÐͬʱ²åÈë¶àÌõÊý¾Ý
ÓÐʱÎÒÃÇ»áÏñÏÂÃæµÄÇé¿öÒ»Ñù£¬ÎªÖ÷±íµÄıһÌõ¼Ç¼£¬ÔÚÖмä±í(T_Stud_Course ±í)ÖÐͬʱ²åÈë¶àÌõÊý¾Ý
T_Student ±í
Stud_ID
Name
1
Tom
2
Jack
T_Course ±í
Course_ID
Course
1
Chinese
2
English
T_Stud_Course ±í
ID
Stud_ID
Course_ID
1
1
1
2
1
2
3
2
2
ÏÖÔÚÎÒÃÇ¿ÉÒÔÏÂÃæµÄ´æ´¢¹ý³ÌÀ´ÊµÏÖ£º
--ΪÖ÷±íµÄıһÌõ¼Ç¼£¬ÔÚÖмä±íÖÐͬʱ²åÈë¶àÌõÊý¾Ý
ALTER proc [dbo].[wholeInsert]
(
@insert_val nvarchar(1000), --ÐÂÔöµÄµÚÒ»¸ö×ֶεÄÖµ£¨¶à¸öÓÑ,’·Ö¸ô£©,ÈçA,B,
@PK_id nvarchar(50), --ÐÂÔöÊý¾ÝµÄµÚ¶þ¸ö×Ö¶ÎÖµ,ͬʱҲÊÇɾ³ý¾ÉÊý¾ÝµÄÌõ¼þ(²»Ö§³Ö¶à¸ö)
@col_1 nvarchar(20), --µÚÒ»¸ö×Ö¶ÎÃû
@col_2 nvarchar(20), --µÚ¶þ¸ö×Ö¶ÎÃû
@Tab nvarchar(20), --±íÃû
)
as
begin
declare @sql varchar(1000)
declare @strVal nvarchar(100)
set @sql='delete from '+@Tab+' where '+@col_2+'='+@PK_id
exec(@sql)
while(len(@insert_val)>0)
begin
set @strVal=substring(@insert_val,1,charindex(',',@insert_val,1)-1)
set @insert_val=substring(@insert_val,charindex(',',@insert_val,1)+1,len(@insert_val)-charindex(',',@insert_val,1))
set @sql='insert into '+@Tab+' ('+@col_1+','+@col_2+') values ('+@strVal+','+@PK_id+')'
exec(@sql)
end
end
Ö´ÐÐ:
Exec wholeInsert '1,2,','1','Course_ID','Stud_ID','T_Stud_Course'
--±íʾͬʱΪStud_ID=1µÄѧÉúÔö¼ÓÁ½ÃſγÌ(Course_IDΪ1ºÍ2)
Ïà¹ØÎĵµ£º
Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“001”¿Î³Ì±È“002”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ£»
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......
ÉÏ»Ø˵µ½£¬²Ù×÷Object Array
Æäʵ»¹¿ÉÒÔÕâÑù²Ù×÷£º
var Room = [
{
ID: 'bot',
name: 'test' ......
1.ʲô½ÐSQL×¢È룿ÈçºÎ·ÀÖ¹£¿Çë¾ÙÀý˵Ã÷
´ð£ºSQL×¢ÈëÊdz£¼ûµÄÀûÓóÌÐò©¶´½øÐй¥»÷µÄ·½·¨¡£µ¼ÖÂsql×¢Èë¹¥»÷²¢·ÇϵͳÔì³ÉµÄ£¬Ö÷ÒªÊdzÌÐòÖкöÂÔÁË°²È«ÒòËØ£¬ÀûÓÃsqlÓïÑÔ©¶´»ñµÃºÏ·¨Éí·ÝµÇ½ϵͳ
ÀýÈ磺
"Select * from users where name='"+uName+"' and pwd='"+uPwd+"' " ......
alert index mem_ct monitoring usage;
desc v$object_usage;
set linesize 190
select * from v$object_usage;
SQL>SET AUTOTRACE ON;
¡¡¡¡*autotrace¹¦ÄÜÖ»ÄÜÔÚSQL*PLUSÀïʹÓÃ
¡¡¡¡ÆäËûһЩʹÓ÷½·¨£º
¡¡¡¡2.2.1¡¢ÔÚSQLPLUSÖеõ½Óï¾ä×ܵÄÖ´ÐÐʱ¼ä
¡¡¡¡SQL> set timing on;
2.2.2¡¢Ö»ÏÔʾִÐмƻ®--(»áÍ¬Ê ......
2010-05-05 13:35:52.06 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
2010-05-05 13:35:52.06 Server (c) 2005 Microsoft Corporation.
201 ......