ms sql : xp_cmdshell
Ïò¸ßÊÖÇë½ÌÒ»¸öÎÊÌâ:
µ±ÎÒÖ´ÐÐ:
use master
exec xp_cmdshell 'osql /S musqlserver /U sa /P mypwd /d haodb /Q "select top 10 * from trandetail" /o C:\my1.xls'
ÒÔÉÏÖ´Ðгɹ¦,»á²úÉúÐÂÎļþ:C:\my1.xls'
È»ºóÎÒÏ뽫´ËÎļþÖ±½Ócopyµ½Áíһ̨µçÄÔÖÐ[Òѽ¨Á¬½Ó]
Ö´ÐÐ
EXEC xp_cmdshell 'copy C:\my1.xls \\192.168.42.42\d$'
ʱºò,ϵͳ»áÌáʾ"¾Ü¾ø·ÃÎÊ"
¶øÔÚDOS´°¿ÚÖÐÖ´ÐÐ:
C:\my1.xls \\192.168.42.42\d$ ÔòûÓÐÈκÎÎÊÌâ
ÎÒÏëÓ¦¸ÃÊÇÓû§È¨ÏÞµÄÎÊÌâ
ÒòΪÔÚsqlÖÐ,Óû§ÊÇsa
ÔÚDOSÖÐ,Óû§ÔòÊÇadministrator
ÄÇÎÒÓ¦¸ÃÔõô×ö??
ÏȽ¨Á¢¹²ÏíÐÅÓùØϵ
master..xp_cmdshell 'net use \\192.168.42.42\d$ 123 /user:domain\administrator'
¹ØÓÚnet useµÄÓ÷¨¿´°ïÖú¡£
exec xp_cmdshell 'net use Z: \\192.168.42.42\d$ /user:domain\administrator'
exec xp_cmdshell 'copy C:\my1.xls Z:\'
exec xp_cmdshell 'net use Z: /del'
Ïà¹ØÎĵµ£º
ÎÒÃÇÏÈ¿´ NestedLoop ºÍ MergeJoin µÄËã·¨£¨ÒÔÏÂΪÒýÓ㬼û RicCC µÄ¡¶ ͨÍùÐÔÄÜÓÅ»¯µÄÌìÌà - µØÓü JOIN ·½·¨ËµÃ÷ ¡· ):
==================================
NestedLoop:
foreach rowA in tableA where tableA.col2=?
{
search rowsB from tableB where tableB.c ......
´óÐÍϵͳµÄÉú²ú»·¾³£¬Ò»°ãÇé¿öÏ£¬ÎÒÃÇÆÀ¼ÛÒ»Ìõ²éѯÊÇ·ñÓÐЧÂÊ£¬¸ü¶àµÄÊǹØ×¢Âß¼ IO( ÖÁÓÚΪʲô£¬»ØÍ·²¹Ò»Æª ) ¡£ÎÒÃdz£Ëµ£¬“Òª½¨±ëº·µÄË÷Òý”¡¢“Ҫд¸ßЧµÄ SQL ”£¬Æäʵ×îÖÕÄ¿µÄ¾ÍÊÇÔÚÏàͬ½á¹û¼¯Çé¿öÏ£¬¾¡¿ÉÄܼõÉÙÂß¼ IO ¡£
1.1 where Ìõ¼þµÄÁÐÉ϶¼µÃÓÐͳ¼ÆÐÅ ......
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
......
Ò». ÒýÑÔ
¡¡¡¡Èç¹ûÄãÔø¾Ê¹ÓÃSQL Server¿ª·¢¹ýÈκÎÈí¼þ£¬ÄÇôÄã¿Ï¶¨»áÏ°¹ßÓÚʹÓÃËIJ¿·Ö±êʶ·ûÀ´²Î¿¼Ò»¸ö¶ÔÏó£º
[[[server.][database].][schema_name].]object_name
¡¡¡¡ÕýÈçÉÏÃæµÄ·½À¨ºÅËùÏÔʾµÄ£¬¸ÃÓï·¨µÄ²»Í¬²¿·Ö¿ÉÒÔ±»ºöÂÔ£¬Ö»ÒªÄãÌṩ×ã¹»µÄ±í´ïÀ´ÎÞ¶þÒåµØ±êʶÄãµÄ¶ÔÏó¼´¿É¡£ÀýÈ磬ÏÂÃæËùÓÐÕâЩ±í´ï¶¼¿ÉÄܲο¼Ïàͬµ ......
select [name] from sysdatabases order by name--µÃµ½Êý¾Ý¿âÖÐËùÓеĿâÃû
select [name] from sysobjects where xtype='U'and [name]<>'dtproperties' order by [name]--µÃµ½Êý¾Ý¿â±íÖеÄÁбí
select [name] from sysobjects where xtype='V' and [name]<>'syssegments' and [name]<>'sysconstraints' ......