SQL»ù±¾Ê¹ÓúʹúÂëÓÅ»¯
EXECºÍsp_executesqlµÄÇø±ð£¿
DBCC FREEPROCCACHE --¡·Çå¿Õ»º´æÖеÄÖ´Ðмƻ®
SELECT cacheobjtype,objtype,usecounts,sql from sys.syscacheobjects WHERE sql NOT LIKE '%cach%' AND sql NOT LIKE '%sys.%' --¡·²éÕÒ¶ÔÓ¦µÄ»º´æÖеĶÔÓ¦¼Æ»®
SQL ServerΪÿһ¸öµÄ²éѯ×Ö·û´®´´½¨ÐµÄÖ´Ðмƻ®£¬¼´Ê¹²éѯģʽÏàͬҲÊÇÕâÑù
EXEC³ýÁ˲»Ö§³Ö¶¯Ì¬Åú´¦ÀíÖеÄÊäÈë²ÎÊýÍ⣬ËûÒ²²»Ö§³ÖÊä³ö²ÎÊý
Ó÷¨£º
Exec('select * from CustInfo')
Exec sp_executesql N'select * from CustInfo'
declare @paraName varchar(20)
set @paraName='CustName'
Exec('select '+@paraName+' from CustInfo')--¼ÓºÅǰºó¼ÓÉϿոñ
Èç¹ûÄãÒª°ÑÊä³ö·µ»Ø¸øµ÷ÓÃÅú´¦ÀíÖеıäÁ¿£º
DECLARE @sql NVARCHAR(MAX),@RecordCount INT
SET @sql = 'SELECT COUNT(ORDERID) from Orders';
CREATE TABLE #T(TID INT);
INSERT INTO #T EXEC(@sql);
SET @RecordCount = (SELECT TID from #T)
SELECT @RecordCount
DROP TABLE #T
sp_executesqlÃüÁîÔÚSQL ServerÖÐÒýÈëµÄ±ÈEXECÃüÁîÍíһЩ£¬ËüÖ÷ÒªÎªÖØÓÃÖ´Ðмƻ®Ìṩ¸üºÃµÄÖ§³Ö¡£
ËüµÄ¹¹³É°üÀ¨£º´úÂë¿ì£¬²ÎÊýÉùÃ÷²¿·Ö£¬²ÎÊý¸³Öµ²¿·Ö
EXEC sp_executesql
@stmt = <statement>,--ÀàËÆ´æ´¢¹ý³ÌÖ÷Ìå
@params = <params>, --ÀàËÆ´æ´¢¹ý³Ì²ÎÊý²¿·Ö
<params assignment> --ÀàËÆ´æ´¢¹ý³Ìµ÷ÓÃ
@stmt²ÎÊýÊÇÊäÈëµÄ¶¯Ì¬Åú´¦Àí£¬Ëü¿ÉÒÔÒýÈëÊäÈë²ÎÊý»òÊä³ö²ÎÊý£¬ºÍ´æ´¢¹ý³ÌµÄÖ÷ÌåÓï¾äÒ»Ñù£¬Ö»²»¹ýËüÊǶ¯Ì¬µÄ£¬¶ø´æ´¢¹ý³ÌÊǾ²Ì¬µÄ£¬²»¹ýÄãÒ²¿ÉÒÔÔÚ´æ´¢¹ý³ÌÖÐʹÓÃsp_executesql;
@params²ÎÊýÓ붨ÒåÊäÈë/Êä³ö²ÎÊýµÄ´æ´¢¹ý³ÌÍ·ÀàËÆ£¬Êµ¼ÊÉϺʹ洢¹ý³ÌÍ·µÄÓï·¨ÍêȫһÑù£»
@<params assignment> Óëµ÷Óô洢¹ý³ÌµÄEXEC²¿·ÖÀàËÆ¡£
Ó÷¨£º
declare @paraName varchar(20)
set @paraName='CustName'
declare @temp nvarchar(1000)
set @temp='select ' +@paraName+ ' from CustInfo'
Exec(@temp)
exec sp_executesql @temp--ÒòΪ sp_executesqlÖ»ÄÜÖ´ÐеÄÀàÐÍΪntext/nchar/nvarchar£¬ËùÒÔ@tempÐèÒª´Óvarchar¸ÄΪnvarchar
DECLARE @TableName VARCHAR(50),@sql NVARCHAR(MAX),@OrderID INT;
SET @TableName = 'CustInfo ';
SET @OrderID = 10;
SET @sql = 'SELECT * from '+QUOTENAME(@TableName) + ' WHER
Ïà¹ØÎĵµ£º
½ñÌì×öSQL ÓÅ»¯£¬²éÕÒÖ´Ðмƻ®Ê±£¬Ö´Ðмƻ®£¬·¢ÏÖ´ËÖ´Ðмƻ®ÓëÒÔÍùµÄ¼Æ»®ÓÐËùÇø±ð£»ÕÒ¼»¥ÁªÍø£¬ÖÕÓÚÕÒһƪÓйØÑо¿±È½ÏÉîÈëµÄÎÄÕ£»
ÔÖ´Ðмƻ®Ê¹ÓõÄÊÇË÷ÒýɨÃ裬ͻȻһÏ»áʹÓÃË÷Òý¸²¸Ç¼¼Êõ£¬Ð§ÂÊ´óÔö£»
SELECT * µÄÕæÏࣺË÷Òý¸²¸Ç(index coverage)
SELECT *µÄЧÂʺÜÔã¸âÂ𣿵±È»£¬ËùÓÐÈ˶¼ÖªµÀÕâÒ»µã£¬µ«ÊÇÎªÊ²Ã´ÄØ£ ......
ÏÖÏó:
ÓÃVS 2008´ò¿ªVS 2005¿ª·¢µÄ±¨±íºó,»á°Ñ±¨±íµ¥ÏòÉý¼¶µ½2008µÄshcema,²»ÄÜÔÙת»Ø2005µÄschema.ÔÙ·¢²¼µ½SQL Server 2005ÉÏʱ»á±¨´í:"ÎÞ·¨Éý¼¶µÄÃû³Æ¿Õ¼ä".
ÕÒµ½µÄ½â¾ö°ì·¨:
ÔÚSQL Server 2005ËùÔڵĻúÆ÷ÉÏ¿ª·¢±¨±í.
°ÑSQL ServerÉý¼¶µ½ SQL Server 2008.
¾Ý˵ÓÐReporting Service 2008µÄµ¥¶À°²×°°æ,¿ÉÒÔ ......
ͨ³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆÚºÍ¼ÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£ÄãÃǴ󲿷ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡
¡¡¡¡ÔÚÕâÆªÎÄÕÂÀÎÒ½«¸æËßÄãÈçºÎʹÓÃDATEADDºÍDATEDIFFº¯ÊýÀ´¼ÆËã³öÔÚÄã ......
PL/SQL DeveloperʹÓü¼ÇÉ
1¡¢PL/SQL Developer¼ÇסµÇ½ÃÜÂë
ÔÚʹÓÃPL/SQL Developerʱ£¬ÎªÁ˹¤×÷·½±ãÏ£ÍûPL/SQL Developer¼ÇסµÇ¼OracleµÄÓû§ÃûºÍÃÜÂ룻
ÉèÖ÷½·¨£ºPL/SQL Developer 7.1.2 ->tools->Preferences->Oracle->Logon History £¬ "Store history"ÊÇĬÈϹ´Ñ¡µÄ£¬¹´ÉÏ"Store wi ......
¸øPL/SQL´´½¨Õ˺š¢ÃÜÂëºÍ¸¶È¨ÏÞ
CREATE USER zxd PROFILE "DEFAULT" IDENTIFIED BY zxd DEFAULT TABLESPACE "USERS" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK
grant dba to "zxd";
F:\oracle\ora92\network\admin ·¾¶ÏÂtnsnames.ora
ZXD =
(DESCRIPTION =
&nb ......