SQLServerµÄÁ½¸öά»¤¼¼ÇÉ
¡¡È·Êµ£¬Êý¾Ý¿âµÄά»¤³£³£½»¸øÄÇЩרҵµÄÊý¾Ý¿â¹ÜÀíÔ±£¬µ«ÊÇ×÷Ϊһ¸ö¿ª·¢Õߣ¬ÄãÒ²Ðíż¶ûÐèÒªÔÝʱ´ÓÊÂÕâ¸ö¹¤×÷¡£ËùÒÔ£¬ÊÔÒ»ÊÔÕâÁ½¸öSQL·þÎñÆ÷ά»¤¼¼ÇÉ£ºÇáËɸıäÊý¾Ý¿âÓµÓÐÕß¡¢ÕûÀíË÷ÒýËéƬ¡£Ë»áÏëµ½ÄãÉõÖÁ¿ÉÒÔ¸øÄÇЩÊý¾Ý¿â¹ÜÀíÔ±½ÌÉÏÒ»Á½¸öм¼ÇÉÄØ£¿ÖØÖ¸¶¨Êý¾Ý¿âÓµÓÐÕßµ±»Ø¸´»òÕßн¨Êý¾Ý¿âʱ£¬ÄãÓÐûÓÐ×¢Òâµ½SQL Server°ÑÊý¾Ý¿âµÄÓµÓÐÕßÖÃΪÄãµÄNTµÇ¼Ãû£¿½ö½öΪÁËÈ·±£²»Í¬Êý¾Ý¿â¼äµÄÒ»ÖÂÐÔ£¨¸ü±ðÌᰲȫÐÔÒòËØÁË£©£¬ÄãÒ²Ðí¿¼ÂÇÓÃϵͳ¹ý³Ìsp_changedbownerÀ´°ÑÊý¾Ý¿âÓµÓÐÕ߸ÄΪÆäËüÓû§Èçϵͳ¹ÜÀíÔ±£¨SA£©¡£ÄãÒ²ÐíÒѾдÁËÕâÑùÒ»¶Î½Å±¾ÓÃÀ´É¨ÃèËùÓÐÓû§Êý¾Ý¿â²¢°ÑÊý¾Ý¿âÓµÓÐÕßÖØÖ¸¶¨ÎªÏµÍ³¹ÜÀíÔ±¡£
¡¡¡¡
¡¡¡¡ÏµÍ³¹ý³Ìsp_changedbownerÓÐÒ»¸ö²ÎÊý£¬¼´@map£¬ÆäȱʡֵΪ¿Õ£¨null£©£¬¸Ã¹ý³Ì¿ÉÒÔ°ÑÊý¾Ý¿â¾ÉÓеÄÓµÓÐÕߵıðÃûÖØÓ³ÉäΪеÄÊý¾Ý¿âÓµÓÐÕߣ¬Èçϵͳ¹ÜÀíÔ±¡£
¡¡¡¡
¡¡¡¡ÎªÁËÑÝʾ¸Ã¹ý³Ì£¬ÈÃÎÒÃÇÊ×ÏȽ¨Á¢Ò»¸ö¾¡¿ÉÄÜСµÄÊý¾Ý¿âÄ£ÐÍ£¬È»ºóÔËÐÐsp_helpuserÖ¸ÁîÀ´¿´¿´Ð´´½¨µÄÓû§ÃûÇåµ¥£º
¡¡¡¡CREATE DATABASE test¡¡¡¡GO¡¡¡¡USE test¡¡¡¡GO¡¡¡¡EXEC sp_helpuser¡¡¡¡GO
¡¡¡¡ÕâЩ´úÂëÖ´Ðкó£¬Êä³öÓ¦¸ÃÁгöÊý¾Ý¿âÓµÓÐÕßµÄÇåµ¥£¨db_owner£©¡£Èç¹ûÄãʹÓÃWindows NTÈÏÖ¤Éí·Ý£¬ÄÇôÇåµ¥ÖÐÓ¦¸ÃÓÐÒ»¸öNULLµÄµÇ¼Ãû×ÖºÍÒ»¸öSIDÖµ¡£
¡¡¡¡
¡¡¡¡È»ºó£¬ÈÃÎÒÃǼÓÉÏÁ½¸öµÇ¼Óû§£ºISUser1ºÍISUser2×÷Ϊdb_ownerµÄ±ðÃû£¬²¢°ÑÊý¾Ý¿âµÄÓµÓÐÕ߸ÄΪϵͳ¹ÜÀíÔ±£º
¡¡¡¡Êä³öÄÚÈÝÓ¦¸ÃÏÔʾ³öϵͳ¹ÜÀíÔ±×÷Ϊdb_owner¡¢ISUser1×÷Ϊdb_ownerµÄ±ðÃû¡£
¡¡¡¡ÏÖÔÚÎÒÃÇÓùý³Ìsp_changedbownerÀ´Ö¸¶¨ISUser2ΪÊý¾Ý¿âеÄÓµÓÐÕß¡£ÎÒÃǽ«Ê¹Óøùý³ÌµÄ@map²ÎÊý²¢°Ñ¸Ã²ÎÊý¸³ÖµÎª“·ñ”£¬ÕâÑù°ÑÓû§½«Îª±ðÃû¡£
¡¡¡¡Êä³öÓ¦¸ÃÏÔʾ³öISUser2ÏÖÔÚ³ÉΪÊý¾Ý¿âеÄÓµÓÐÕߣ¬ISUser1½µÎª±ðÃû¡£ÏÂÃ棬ÎÒÃÇÓ¦¸ÃÍ£Ö¹Õâ¸öÊý¾Ý¿â²¢½áÊø±¾ÑÝʾ¹ý³Ì¡£
ÓÃDBCC INDEXDEFRAGÃüÁîÀ´ÊµÏÖά»¤
¡¡¡¡¶ÔË÷Òý½øÐÐά»¤¹¤×÷ÊÇÒ»¼þÈß³¤·ÑÁ¦µÄ¹¤×÷£¬²»¹ýÔÚSQL Server 2000ÖУ¬Î¢ÈíÒѾÒýÈëÁËÒ»Ìõά»¤ÃüÁîDBCC INDEXDEFRAG£¬ËüÏà¶ÔSQL Server7.0µÄDBREINDEXÃüÁîÀ´Ëµ£¬Óкü¸¸öÓŵ㡣×îÖ÷ÒªµÄÓŵã¾ÍÊÇËüÊÇÒ»ÖÖÔÚÏß²Ù×÷£¬ÕâÑù£¬ÔÚ¸ÃÃüÁîÔËÐÐÆÚ¼äÓû§ÈÔ¿ÉÒÔÁ¬Ðø¹¤×÷¡£ÕâÊÇÒòΪËü²»ÏñDBREINDEXÄÇÑùÔÚÔËÐÐʱÐèÒªËø¶¨²Ù×÷ËùÉæ¼°µÄ×ÊÔ´£¬Ëü»¹¿ÉÒÔ½µµÍÄÚÈÝ×èÈû¡£
¡¡¡¡DBCC INDEXDEFRAG²Ù×÷һС¶Î¡¢Ò»Ð¡¶ÎµÄÊý¾Ý£¬ÕâÑù¸Ã²Ù×÷Ëæʱ¶¼¿ÉÒÔÍ£Ö¹ÏÂÀ´²¢¸ú×ÙËüÒѾÍê³ÉµÄ¹¤×÷¡£¸Ã²Ù×÷ÿ¸ôÎå·ÖÖӾͱ¨¸æÒ»´
Ïà¹ØÎĵµ£º
¼ÌÐøSQLServerË÷Òýµ÷ÓÅʵ¼ù¡£Õâ´Î̽ÌÖÒ»ÏÂË÷Òý¸²¸Ç - SQL ServerÖ÷ҪʹÓÃË÷ÒýÈ¥²éѯÄãÐèÒªµÄÊý¾Ý£¬µ±Ë÷Òý°üÀ¨ËùÓеÄÄãÇëÇó²éѯµÄ×ֶΣ¬SQL Server½«²»ÐèҪȥÔÚ±íÖвéѯ¡£Õâ¸ö¸ÅÄî³Æ×ö“Ë÷Òý¸²¸Ç”¡£
SQLServer2005µÄNon-clustered INDEXÔö¼ÓÁËÒ»¸ö“°üº¬ÁÐ(included column)
”Ñ¡Ïî¡£ÔÚ SQL Server 2 ......
//×ܼǼÊý
function sumRecord()
{
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select count(*) as RecordCount from baoming";
rs.open(sql, ......
sqlite¹Ù·½Õ¾
http://www.sqlite.org/
SQL Syntax
http://www.sqlite.org/lang.html
sqliteÖÐÎÄÕ¾
http://www.sqlite.com.cn/
http://www.sqlitechina.org/
½¨Á¢Êý¾Ý¿âµµ°¸
ÓÃsqlite3½¨Á¢Êý¾Ý¿âµÄ·½·¨ºÜ¼òµ¥£¬Ö»ÒªÔÚshellϼüÈ루ÒÔÏÂ$·ûºÅΪshellÌáʾºÅ£¬ÇëÎð¼üÈ룩£º
$ sqlite3 foo.db
Èç¹ûĿ¼ÏÂûÓÐfo ......
--spid:ËÀËøµÄ½ø³Ì,tableName :ËÀËøµÄ±í
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id)tableName from sys.dm_tran_locks
where resource_type='OBJECT'
--spid:Òª½áÊøµÄ½ø³Ìid
kill spid ......