Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¾­µäSQLÓï¾ä´óÈ«

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡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
¡¡¡¡4¡¢ËµÃ÷£º´´½¨Ð±í
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
¡¡¡¡¸ù¾ÝÒÑÓÐµÄ±í´´½¨ÐÂ±í£º
A£ºcreate table tab_new like tab_old (ʹÓÃ¾É±í´´½¨Ð±í)
B£ºcreate table tab_new as select col1,col2… from tab_old definition only
¡¡¡¡5¡¢ËµÃ÷£º
¡¡¡¡É¾³ýÐÂ±í£ºdrop table tabname
¡¡¡¡6¡¢ËµÃ÷£º
¡¡¡¡Ôö¼ÓÒ»¸öÁУºAlter table tabname add column col type
¡¡¡¡×¢£ºÁÐÔö¼Óºó½«²»ÄÜɾ³ý¡£DB2ÖÐÁмÓÉϺóÊý¾ÝÀàÐÍÒ²²»Äܸı䣬ΨһÄܸıäµÄÊÇÔö¼ÓvarcharÀàÐ͵ij¤¶È¡£
¡¡¡¡7¡¢ËµÃ÷£º
¡¡¡¡Ìí¼ÓÖ÷¼ü£ºAlter table tabname add primary key(col)
¡¡¡¡ËµÃ÷£º
¡¡¡¡É¾³ýÖ÷¼ü£ºAlter table tabname drop primary key(col)
¡¡¡¡8¡¢ËµÃ÷£º
¡¡¡¡´´½¨Ë÷Òý£ºcreate [unique] index idxname on tabname(col….)
¡¡¡¡É¾³ýË÷Òý£ºdrop index idxname
¡¡¡¡×¢£ºË÷ÒýÊDz»¿É¸ü¸ÄµÄ£¬Ïë¸ü¸Ä±ØÐëɾ³ýÖØн¨¡£
¡¡¡¡9¡¢ËµÃ÷£º
¡¡¡¡´´½¨ÊÓͼ£ºcreate view viewname as select statement
¡¡¡¡É¾³ýÊÓͼ£ºdrop view viewname
10¡¢ËµÃ÷£º¼¸¸ö¼òµ¥µÄ»ù±¾µÄsqlÓï¾ä
¡¡¡¡Ñ¡Ôñ£ºselect * from table1 where ·¶Î§
¡¡¡¡²åÈ룺insert into table1(field1,field2) values(value1,value2)
¡¡¡¡É¾³ý£ºdelete from table1 where ·¶Î§
¡¡¡¡¸üУºupdate table1 set field1=value1 where ·¶Î§
¡¡¡¡²éÕÒ£ºselect * from table1 where field1 like ’%value1%’ ---likeµÄÓï·¨ºÜ¾«Ã²é×ÊÁÏ!
¡¡¡¡ÅÅÐò£ºselect * from table1 order by field1,field2 [desc]
¡¡¡¡×ÜÊý£ºselect count * as totalcount from table1
¡¡¡¡ÇóºÍ£ºselect sum(field1) as sumvalue from table1
¡¡¡


Ïà¹ØÎĵµ£º

v$sql,v$sqlarea,v$sqltextÓÐʲôÇø±ð

http://inthirties.com:90/thread-1202-1-1.html
v$sqltext
´æ´¢µÄÊÇÍêÕûµÄSQL,SQL±»·Ö¸î
SQL> desc v$sqltext
Name Null? Type
----------------------------------------- -------- ----------------------------
ADDRESS ......

²¹³ä£ºv$sql,v$sqlarea,v$sqltextÓÐʲôÇø±ð

http://inthirties.com:90/thread-1202-1-1.html
Ç°ÃæÎÄÕ ”v$sql,v$sqlarea,v$sqltextÓÐʲôÇø±ð“ ¼û http://blog.csdn.net/inthirties/archive/2010/03/10/5364777.aspx
ÕâÀï²¹³äÒ»ÏÂ
²¹³ä£º
1¡¢²éÒ»ÏÂÕâЩÊÓͼµÄ¶¨ÒåÄã¾ÍÄÜÀí½â£¬ËüÃǵÄÔ´¶¼ÊÇÒ»¸ö¡£
SELECT view_definition from v$fixed_view_definiti ......

.net³ÌÐòÔ±ËùÐèÕÆÎÕµÄsql£¬»ù±¾¼¼ÇÉ(1)

1¡¢SessionÓÐʲôÖØ´óBUG£¬Î¢ÈíÌá³öÁËʲô·½·¨¼ÓÒÔ½â¾ö£¿
  ´ð£ºÊÇiisÖÐÓÉÓÚÓнø³Ì»ØÊÕ»úÖÆ£¬ÏµÍ³·±Ã¦µÄ»°Session»á¶ªÊ§£¬¿ÉÒÔÓÃSate server»òSQL ServerÊý¾Ý
¿âµÄ·½Ê½´æ´¢Session²»¹ýÕâÖÖ·½Ê½±È½ÏÂý£¬¶øÇÒÎÞ·¨²¶»ñSessionµÄENDʼþ¡£
2.²úÉúÒ»¸öintÊý×飬³¤¶ÈΪ100£¬²¢ÏòÆäÖÐËæ»ú²åÈë1-100£¬²¢ÇÒ²»ÄÜÖظ´¡£
C# ......

sql server·ÃÎÊÔ¶³ÌÊý¾Ý¿â

--´´½¨Á´½Ó·þÎñÆ÷
exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', 'Ô¶³Ì·þÎñÆ÷Ãû»òipµØÖ· '
exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, 'Óû§Ãû ', 'ÃÜÂë '
--²éѯʾÀý
select * from ITSV.Êý¾Ý¿âÃû.dbo.±íÃû
--µ¼ÈëʾÀý
select * into ±í from ITSV.Êý¾Ý¿âÃû.dbo.±íÃû
--ÒÔºó²» ......

Sql server ʱ¼ä¶Î²éѯ µÄÏà¹Ø·Ñ½âÎÊÌâ

sql server ʱ¼ä¶Î²éѯ¡£
==========================================
select g.borrowTime  from t_apartment_goodsborrow g
where g.borrowTime >= '2010-03-11 9:50:43'
2010-03-11 9:52:54
----------------------------------------------------------------------------
select g.borrowTime  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ