ʹÓÃT SQL»ñÈ¡µ½SQLServer IpºÍ¶Ë¿ÚºÅ
ÔÚƽʱµÄ¹¤×÷¹ý³ÌÖУ¬×÷ΪDBA½ÇÉ«¹ÜÀíÊý¾Ý¿â£¬Í·ÄÔÖеÄÓ¡ÏóÍùÍùÊÇÊý¾Ý¿âʵÀýÃû³Æ£¬¶ø²»»áÈ¥¹ØÐÄServerµÄIP£¬¶ø×÷ΪDeveloperµÄ½ÇÉ«£¬ËûÃÇÍùÍùÏëÖªµÀÖªµÀServer IpºÍ¶Ë¿ÚºÅ¡£ËùÒÔ£¬DBA»á¾³£±»Îʼ°µ½£ºXXXʵÀýµÄIPºÍ¶Ë¿ÚºÅÊÇʲô£¿
Õâ¸öÎÊÌ⣬µ±È»ÎÒÃÇ¿ÉÒÔLoginµ½OS²é¿´IP¡¢Ê¹ÓÃÅäÖƹÜÀí¹¤¾ß»ñÈ¡µ½¶Ë¿ÚºÅ¡£µ«ÊÇ£¬Õâ¸ö·½·¨·Ç³£µÄÂé·³£¬´ï²»µ½DBA¸ßЧ¿ìËÙ·´Ó¦µÄÒªÇó¡£
ÄÇô£¬ÕâƪÎÄÕ¾ÍÊÇΪÁ˽â¾öЧÂÊÎÊÌ⣬ʹÓÃÏÂÃæµÄSQL Script¿ÉÒÔÇáËɵĻñÈ¡µ½SQLServer IpºÍ¶Ë¿ÚºÅ¡£
USE master
GO
DECLARE @tcpEndport VARCHAR(20)
,@regeditKey VARCHAR(100)
/**Enable xp_cmdshell
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
**/
--SQLServer 2000
IF @@VERSION LIKE 'Microsoft SQL Server 2000%'--SQLServer 2000
BEGIN
SET @regeditKey= N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib\Tcp'
EXEC master.dbo.xp_regread
@rootkey='HKEY_LOCAL_MACHINE'
,@key= @regeditKey
,@value_name='TcpPort'
,@value=@tcpEndport OUTPUT
END
/*
SQLServer 2005 and SQLServer 2008
*/
ELSE
BEGIN
IF @@Servicename='MSSQLSERVER'--Default instance
BEGIN
SET @regeditKey='SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib\Tcp'
END
ELSE
BEGIN
SET @regedi
Ïà¹ØÎĵµ£º
1.sqlÊÇÒ»Öֽű¾ÓïÑÔ
2.sql¿Éд½Å±¾³ÌÐò£¬µ«×îÖØÒªµÄ×÷Ó÷¢»ÓÔÚ¶ÔÊý¾Ý¿âµÄ²Ù×÷ÉÏ
3.sql server2005ÖеÄ×¢ÊÍÓÐÁ½ÖÖ/***/¶àÐÐ×¢ÊÍ£¬--¿ÉÒÔµ¥ÐÐ×¢ÊÍ
4.sqlÖеÄ×Ô¶¨Òå±äÁ¿ÒÔ@¿ªÍ·£¬ÏµÍ³±äÁ¿ÒÔ@@¿ªÍ·
5.sqlÖÐÉùÃ÷±äÁ¿ºÍVBÀàËÆ£¬Ê¹ÓÃdeclareÉùÃ÷±äÁ¿È磺declare @i int,@j int£¬´ËÓï¾äÉùÃ÷ÁË2¸öÕûÐαäÁ¿@iºÍ@j
6.sqlÖеÄÊý¾Ý ......
ÀýÈ磺
ÆÕ±éµÄSQLÓï¾ä£º
update book set bookname='sssss' where bookId=1;
ÔÚPL/SQL ÖÐÖ´ÐУº
declare
v_book ......
ÔÚPL/SQLÖÐÒýÈëÁË¿ØÖƽṹ£¬°üÀ¨Ñ¡Ôñ½á¹¹£¬Ñ»·½á¹¹ºÍÌøת½á¹¹
Ò» Ñ¡Ôñ½á¹¹
1,IF Óï¾ä
ÔÚPL/SQLÖУ¬Ñ¡Ôñ½á¹¹¿ÉÒÔͨ¹ýifÓï¾äÀ´ÊµÏÖ£¬Ò²¿ÉÒÔͨ¹ýCaseÓï¾ä£¨oracle9iÖУ©
ÀûÓÃifÓï¾äʵÏÖÑ¡Ôñ¿ØÖƵÄÓ﷨Ϊ£º
if condition1 then statements1 ......
ÔÚ½éÉÜGROUP BY ºÍ HAVING ×Ó¾äÇ°£¬ÎÒÃDZØÐèÏȽ²½²sqlÓïÑÔÖÐÒ»ÖÖÌØÊâµÄº¯Êý£º¾ÛºÏº¯Êý£¬ÀýÈçSUM, COUNT, MAX, AVGµÈ¡£ÕâЩº¯ÊýºÍÆäËüº¯ÊýµÄ¸ù±¾Çø±ð¾ÍÊÇËüÃÇÒ»°ã×÷ÓÃÔÚ¶àÌõ¼Ç¼ÉÏ¡£
SELECT SUM(population) from bbc
¡¡¡¡ÕâÀïµÄSUM×÷ÓÃÔÚËùÓзµ»Ø¼Ç¼µÄpopulation×Ö¶ÎÉÏ£¬½á¹û¾ÍÊǸòéÑ ......
˵Ã÷£ºÒÔÏÂÎåÊ®¸öÓï¾ä¶¼°´ÕÕ²âÊÔÊý¾Ý½øÐйý²âÊÔ£¬×îºÃÿ´ÎÖ»µ¥¶ÀÔËÐÐÒ»¸öÓï¾ä¡£
ÎÊÌâ¼°ÃèÊö£º
--1.ѧÉú±í
Student(S#,Sname,Sage,Ssex) --S# ѧÉú±àºÅ,Sname ѧÉúÐÕÃû,Sage ³öÉúÄêÔÂ,Ssex ѧÉúÐÔ±ð
--2.¿Î³Ì±í
Course(C#,Cname,T#) --C# --¿Î³Ì±àºÅ,Cname ¿Î³ÌÃû³Æ,T# ½Ìʦ±àºÅ
--3.½Ìʦ±í
Teacher(T#,Tname) -- ......