³£ÓÃsqlÓï¾ä
1.ÏÞÖÆ·µ»Ø¼Ç¼µÄÐÐÊý£¨4-10ÐУ©
select rownum,c1 from t144 where rownum<10
minus
select rownum,c1 from t144 where rownum<5
2.ÅúÁ¿²åÈë
insert into tablename(select * from othertable)
»ò
insert into (column1,column2,,,,,,,)tablename(select column1,column2,,,,,,,from othertable)
3,·Ö×麯Êý(½á¹ûÖгöÏÖµÄÁÐÒªÔÚgroup by ÖгöÏÖ)
select count(age), username, , ,... from table group by age,usename,,,,...
4.²é¿´Êý¾Ý¿âÖеĴæÔڵıí
select table_name from dba_tables (include all users)
select * from tab(include view)
5.¸ßЧupdate£¬Ò»´ÎÐ޸Ķà¸öÁÐ
update smsmonitor sms
set (sms.smsmonitor_sendflag, sms.smsmonitor_maxnum) = (select s.smsmonitor_sendflag,
s.smsmonitor_maxnum
from smsmonitor s
where s.smsmonitor_id =
&nbs
Ïà¹ØÎĵµ£º
Êý¾Ý¿âËùÓÐÕß (DataBase Owner)
dbo ÊǾßÓÐÔÚÊý¾Ý¿âÖÐÖ´ÐÐËùÓлµÄ°µÊ¾ÐÔȨÏÞµÄÓû§¡£½«¹Ì¶¨·þÎñÆ÷½ÇÉ« sysadmin µÄÈκγÉÔ±¶¼Ó³É䵽ÿ¸öÊý¾Ý¿âÄÚ³ÆΪ dbo µÄÒ»¸öÌØÊâÓû§ÉÏ¡£ÁíÍ⣬Óɹ̶¨·þÎñÆ÷½ÇÉ« sysadmin µÄÈκγÉÔ±´´½¨µÄÈκζÔÏó¶¼×Ô¶¯ÊôÓÚ ......
Ê×ÏȼÆËã»úÉϱØÐë°²×°oracle£¬²¢ÅäÖú÷þÎñÃû
°²×°oracleµÄ¹ý³ÌÖÐÒ»°ã»áÒªÇó½¨Á¢Ò»¸öÊý¾Ý¿â£¬Ò²¿ÉÒÔÖ®ºóÔÙ´´½¨
Õâ¸öºóÃæÓÐÒ»¸ö Êý¾Ý¿âÅäÖÃÖúÀí £¨´´½¨ÐÞ¸ÄÊý¾Ý¿âµÄ£¬Ò»°ãÃÜÂë´´½¨ÒªÇó×Öĸ¿ªÍ·£¬´óÓÚ7λɶµÄ£©ºÍÒ»¸önetÅäÖÃÖúÀí£¨Ìí¼Ó»òÕßÐÞ¸ÄÒ»¸öÊý¾Ý¿â·þÎñÃû£©£¬Ò»°ãÓÃplsql developerÔ¶³Ì²Ù×÷oracleÊý¾Ý¿â ......
SQL²Ù×÷È«¼¯
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE ......
1.¶¨Òå»ù±¾±íÓï¾ä
Óï·¨£º
USE Êý¾Ý¿âÃû CREATE TABLE ±íÃû (ÁÐÃû ÀàÐÍ(´óС) DEFAULT'ĬÈÏÖµ',
& ......
sqlÓïÑÔÖÐÓÐûÓÐÀàËÆCÓïÑÔÖеÄswitch caseµÄÓï¾ä£¿£¿
ûÓÐ,ÓÃcase when À´´úÌæ¾ÍÐÐÁË.
ÀýÈç,ÏÂÃæµÄÓï¾äÏÔʾÖÐÎÄÄêÔÂ
select getdate() as È ......