¡¾×ª¡¿sql½âÎö²½Ö裬Ӳ½âÎöºÍÈí½âÎö
ÎÒÃǶ¼ÖªµÀÔÚOracleÖÐÿÌõSQLÓï¾äÔÚÖ´ÐÐ֮ǰ¶¼ÐèÒª¾¹ý½âÎö£¬ÕâÀïÃæÓÖ·ÖΪÈí½âÎöºÍÓ²½âÎö¡£ÔÚOracleÖдæÔÚÁ½ÖÖÀàÐ͵ÄSQLÓï¾ä£¬Ò»ÀàΪ
DDLÓï¾ä£¨Êý¾Ý¶¨ÒåÓïÑÔ£©£¬ËûÃÇÊÇ´ÓÀ´²»»á¹²ÏíʹÓõģ¬Ò²¾ÍÊÇÿ´ÎÖ´Ðж¼ÐèÒª½øÐÐÓ²½âÎö¡£»¹ÓÐÒ»Àà¾ÍÊÇDMLÓï¾ä£¨Êý¾Ý²Ù×ÝÓïÑÔ£©£¬ËûÃÇ»á¸ù¾ÝÇé¿öÑ¡Ôñ
Ҫô½øÐÐÓ²½âÎö£¬ÒªÃ´½øÐÐÈí½âÎö¡£
DML:INSERT,UPDATE,DELETE,SELECT
DDL:CREATE,DROP,ALTER
SQLÓï¾äµÄ½âÎö²½Ö裬µ±Ò»ÌõSQLÓï¾ä´Ó¿Í»§¶Ë½ø³Ì´«µÝµ½·þÎñÆ÷¶Ë½ø³Ìºó£¬ÐèÒªÖ´ÐÐÈçϲ½Ö裺
1ÔÚ¹²Ïí³ØÖÐËÑË÷ SQL Óï¾äµÄÏÖÓи±±¾
2ÑéÖ¤ SQL Óï¾äµÄÓï·¨ÊÇ·ñ׼ȷ
3Ö´ÐÐÊý¾Ý×Öµä²éÕÒÀ´ÑéÖ¤±íºÍÁеĶ¨Òå
4»ñÈ¡¶ÔÏóµÄ·ÖÎöËøÒÔ±ãÔÚÓï¾äµÄ·ÖÎö¹ý³ÌÖжÔÏóµÄ¶¨Òå²»»á¸Ä±ä
5¼ì²éÓû§·ÃÎÊÒýÓ÷½°¸¶ÔÏóµÄȨÏÞ
6È·¶¨Óï¾äµÄ×î¼ÑÖ´Ðмƻ®
6Óï¾äºÍÖ´Ðмƻ®ÔØÈë¹²ÏíµÄ SQL Çø
ÔÀ´£¬ÎÒÈÏΪӲ½âÎö¾ÍÊÇÉÏÃ漸¸ö²½Öè¡£Ïà¶ÔÓÚÓ²½âÎö£¬Èí½âÎöµÄ²½Öè¾ÍÊÇÉÏÃæµÚÒ»²½ÕÒµ½ÏÖÓÐSQLÓï¾äµÄ¸±±¾ºó£¬Ö»ÐèÒªÑéÖ¤Óû§ÊÇ·ñÓÐȨÏÞÖ´ÐоÍÊÇÁË£¬ÕâÑùÊ¡ÂÔÉÏÃæºÃ¼¸¸ö²½Ö裬Ïà¶ÔÓ²½âÎöÀ´ËµÐÔÄÜ¿ªÏú¾Í·Ç³£Ð¡ÁË¡£
ºóÀ´²ÅÖªµÀÉÏÃæµÄÕæÕýµÄ½âÎö²½Öè²»ÊÇÕâÑùµÄ¡£
ÊÂʵÉÏ£¬ÔÚOracleÖÐSQLÓï¾äµÄ½âÎö²½ÖèÈçÏ£º
1¡¢ Óï·¨¼ì²â¡£ÅжÏÒ»ÌõSQLÓï¾äµÄÓï·¨ÊÇ·ñ·ûºÏSQLµÄ¹æ·¶£¬±ÈÈçÖ´ÐУºSQL> selet * from emp;ÎÒÃǾͿÉÒÔ¿´³öÓÉÓÚSelect¹Ø¼ü×ÖÉÙÁËÒ»¸ö“c”£¬ÕâÌõÓï¾ä¾ÍÎÞ·¨Í¨¹ýÓï·¨¼ìÑéµÄ²½ÖèÁË¡£
2¡¢ ÓïÒå¼ì²é¡£Óï·¨ÕýÈ·µÄSQLÓï¾äÔÚ½âÎöµÄµÚ¶þ¸ö²½Öè¾ÍÊÇÅжϸÃSQLÓï¾äËù·ÃÎÊµÄ±í¼°ÁÐÊÇ·ñ׼ȷ£¿Óû§ÊÇ·ñÓÐȨÏÞ·ÃÎÊ»ò¸ü¸ÄÏàÓ¦µÄ±í»òÁУ¿
±ÈÈçÈçÏÂÓï¾ä£º
SQL> select * from emp;
select * from emp
*
ERROR at line 1:
ORA-00942: table or view does not exist
ÓÉÓÚ²éѯÓû§Ã»Óпɹ©·ÃÎʵÄemp¶ÔÏó£¬Òò´Ë¸ÃSQLÓï¾äÎÞ·¨Í¨¹ýÓïÒå¼ì²é¡£
3¡¢ ¼ì²é¹²Ïí³ØÖÐÊÇ·ñÓÐÏàͬµÄÓï¾ä´æÔÚ¡£¼ÙÈçÖ´ÐеÄSQLÓï¾äÒѾÔÚ¹²Ïí³ØÖдæÔÚͬÑùµÄ¸±±¾£¬ÄÇô¸ÃSQLÓï¾ä½«»á±»Èí½âÎö£¬Ò²¾ÍÊÇ¿ÉÒÔÖØÓÃÒѽâÎö¹ýµÄÓï¾äµÄÖ´Ðмƻ®ºÍÓÅ»¯·½°¸£¬¿ÉÒÔºöÂÔÓï¾ä½âÎö¹ý³ÌÖÐ×îºÄ·Ñ×ÊÔ´µÄ²½Ö裬ÕâÒ²ÊÇÎÒÃÇΪʲôһֱǿµ÷±ÜÃâÓ²½âÎöµÄÔÒò¡£
Õâ¸ö²½ÖèÓÖ¿ÉÒÔ·ÖΪÁ½¸ö²½Ö裺
£¨1¡¢£©ÑéÖ¤SQLÓï¾äÊÇ·ñÍêÈ«Ò»Ö¡£
ÔÚ
Õâ¸ö²½ÖèÖУ¬Oracle½«»á¶Ô´«µÝ½øÀ´µÄSQLÓï¾äʹÓÃHASHº¯ÊýÔËËãµÃ³öHASHÖµ£¬ÔÙÓë¹²Ïí³ØÖÐÏÖÓÐÓï¾äµÄHASHÖµ½øÐбȽϿ´ÊÇ·ñÒ»Ò»¶ÔÓ¦¡£ÏÖ
ÓÐÊý¾Ý¿âÖÐSQLÓï¾äµÄHASHÖµÎÒÃÇ¿É
Ïà¹ØÎĵµ£º
SQL°´ÕÕÈÕ¡¢ÖÜ¡¢Ô¡¢Äêͳ¼ÆÊý¾Ý ÊÕ²Ø
ÎÄÕ²ο¼£ºhttp://www.cnblogs.com/wenbhappy/archive/2008/07/02/1233660.html
Èç:
±í:consume_record
×Ö¶Î:consume (moneyÀàÐÍ)
date (datetimeÀàÐÍ)
ÇëÎÊÔõôдËÄÌõsqlÓï¾ä·Ö±ð°´ÈÕ,°´ÖÜ,°´ÔÂ,°´¼¾Í³¼ÆÏû·Ñ×ÜÁ¿.
Èç:1ÔÂ 1200Ô ......
create table tb (ptoid int,proclassid int,proname varchar(10))
insert tb
select 1,1,'Ò·þ1'
union all
select 2,2,'Ò·þ2'
union all
select 3,3,'Ò·þ3'
union all
select 4,3,'Ò·þ4'
union all
select 5,2,'Ò·þ5'
union all
select 6,2,'Ò·þ6'
union all
select 7,2,'Ò·þ7'
union all
select 8 ......
1 MySQLÖ§³Öenum,ºÍsetÀàÐÍ£¬SQL Server²»Ö§³Ö
¡¡¡¡2 MySQL²»Ö§³Önchar,nvarchar,ntextÀàÐÍ
¡¡¡¡3 MySQLµÄµÝÔöÓï¾äÊÇAUTO_INCREMENT£¬¶øMS SQLÊÇidentity(1,1)
¡¡¡¡4 MS SQLĬÈϵ½´¦±í´´½¨Óï¾äµÄĬÈÏÖµ±íʾÊÇ((0)),¶øÔÚMySQLÀïÃæÊDz»ÔÊÐí´øÁ½À¨ºÅµÄ
¡¡¡¡5 MySQLÐèҪΪ±íÖ¸¶¨´æ´¢ÀàÐÍ
¡ ......
ÔÚsql²éѯ·ÖÎöÆ÷ÀïÃæÊDz»ÄÜÖ±½ÓÔËÐÐcmdÃüÁîµÄ
µ«ÊÇSQL¸ø³öÁËÒ»¸ö½Ó¿Ú
--´ò¿ª¸ß¼¶ÉèÖÃ
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
--´ò¿ªxp_cmdshellÀ©Õ¹´æ´¢¹ý³Ì
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
Ê×ÏÈ ´ò¿ªÒ»Ð©ÅäÖÃ
È»ºóÖ´ÐÐÄãÒªÔËÐÐcmdÃüÁî
exec master..xp_cmdshell 'net star ......
C#ÖÐÒÔwindowsÑéÖ¤·½Ê½Á¬½ÓSQL serverÊý¾Ý¿âµÄÀà¡£ºÜ¶àÈËÁ¬½ÓÊý¾Ý¿âʱ¿ÉÄܶ¼ÊÇÍøÉϲéÁËÈ»ºó¾ÍÁ¬ÁË£¬¶ÔÓÚ²ÎÊýµÄº¬Òåµ¹ÊÇûÔõôÔÚÒ⣬żҲÊÇ£¨ºÇºÇ£©£¬µ±È»ÎÒÃǶ¼×¢Öؽá¹ûÂ¿ÉÊÇÕâÑù²»ÈÝÒ×¼ÇÒäÿ´ÎÁ¬µÄʱºò¶¼ÊÇÉÏÍø²é£¬¸Ð¾õͦ²»·½±ã£¬ËùÒÔË÷ÐÔ²éÁËһϡ£~~~Integrated Security=True£»±íʾÔÚÁ¬½ÓÊý¾Ý¿â½øÐÐÉí·ÝÑé֤ʱÓÃwind ......