³£ÓÃSQLÓï¾äÊÕ¼¯
1.ɾ³ý±í
select 'drop table ' || table_name || ' purge;'
from user_tables
where length(table_name) <= 4;
ɾ³ý´øÔ¼ÊøµÄ±í
Drop table ±íÃû cascade constraints;
2.²éѯview&ͬÒå´Ê
--˵Ã÷£º¿ÉÒÔ¸ù¾ÝÊÓͼµÄtext_lengthÖµÉ趨set long µÄ´óС
set long 2000;
select * from user_views where view_name='MY_VIEW_NAME';
select * from all_views where view_name='MY_VIEW_NAME';
select * from user_synonyms;
3.ÁÙʱ±í
create global temporary table xay_temp as select * from xay;
on commit preserve rows/on commit delete rows
ÔÚOracleÖУ¬¿ÉÒÔ´´½¨ÒÔÏÂÁ½ÖÖÁÙʱ±í:
a »á»°ÌØÓеÄÁÙʱ±í:
create global temporary table () on commit preserve rows;
»á»°Ö¸¶¨£¬µ±ÖжϻỰʱORACLE½«½Ø¶Ï±í
b ÊÂÎñÌØÓеÄÁÙʱ±í:
create global temporary table () on commit delete rows;
ÊÂÎñÖ¸¶¨,ÿ´ÎÌá½»ºóORACLE½«½Ø¶Ï±í£¨É¾³ýÈ«²¿ÐУ©
c ˵Ã÷
ÁÙʱ±íÖ»ÔÚµ±Ç°Á¬½ÓÄÚÓÐЧ
¡¡ ÁÙʱ±í²»½¨Á¢Ë÷Òý,ËùÒÔÈç¹ûÊý¾ÝÁ¿±È½Ï´ó»ò½øÐжà´Î²éѯʱ,²»ÍƼöʹÓÃ
¡¡ Êý¾Ý´¦Àí±È½Ï¸´ÔÓµÄʱºòʱ±í¿ì,·´Ö®ÊÓͼ¿ìµã
4.Ìî¼Ó×¢ÊÍ
comment on table ±íÃû is '×¢ÊÍ';
comment on column ±íÃû.ÁÐÃû is '×¢ÊÍ';
5. ROWNUM
°´É趨ÅÅÐòµÄÐеÄÐòºÅ
SELECT * from emp WHERE ROWNUM < 10 ;
6. ROWID
·µ»ØÐеÄÎïÀíµØÖ·
SELECT ROWID, ename from emp WHERE deptno = 20 ;
7. ¸´ÖƱ
Ïà¹ØÎĵµ£º
declare @i int
set @i=1
while @i<30
begin
insert into test (userid) values(@i)
set @i=@i+1
end
---------------
while Ìõ¼þ
begin
Ö´ÐвÙ×÷
set @i=@i+1
end
WHILE
ÉèÖÃÖظ´Ö´ÐÐ SQL Óï¾ä»òÓï¾ä¿éµÄÌõ¼þ¡£Ö»ÒªÖ¸¶¨µÄÌõ¼þΪÕ棬¾ÍÖظ´Ö´ÐÐÓï¾ä¡£¿ÉÒÔʹÓà BREAK ºÍ CONTINUE ¹Ø¼ü×ÖÔÚÑ»·ÄÚ²¿¿ØÖÆ W ......
[MySQLÓÅ»¯] -- ÈçºÎ²éÕÒSQLЧÂʵØϵÄÔÒò
ʱ¼ä:2010-2-28À´Ô´:HaCMS¿ªÔ´ÉçÇø ×÷Õß:chusong
²éѯµ½Ð§ÂÊµÍµÄ SQL Óï¾ä ºó£¬¿ÉÒÔͨ¹ý EXPLAIN »òÕß DESC ÃüÁî»ñÈ¡ MySQL ÈçºÎÖ´ÐÐ SELECT Óï¾äµÄÐÅÏ¢£¬°üÀ¨ÔÚ SELECT Óï¾äÖ´Ðйý³ÌÖбíÈçºÎÁ¬½ÓºÍÁ¬½ÓµÄ˳Ðò£¬±ÈÈçÎÒÃÇÏë¼ÆËã 2006 ÄêËùÓй«Ë¾µÄÏúÊ۶ÐèÒª¹ØÁª sales ......
select *
from (
select soft.NETMODEL,
soft.softname,
soft.softid ......
1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿)
¡¡¡¡7¡¢Ëø»òÕßËÀËø(ÕâÒ²ÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐ ......
-- ²é¿´µ±Ç°dbµÄµÇ½
select * from sys.sql_logins
-- ÉóºËµÇ½Êý¾Ý¿âµÄÓû§
sql server managerment studioÖУ¬ÓÒ¼üµã¿ª·þÎñÆ÷µÄÊôÐÔ£¬ÔÚ°²È«ÐÔҳǩÖУ¬ Ñ¡ÖÐÉóºË“³É¹¦ºÍʧ°ÜµÄµÇ½”£¬ËùÓеǽ¶¼»áÔÚ..MSSQL\Log\ERRORLOGÖмǼһÌõ¼Ç¼¡£
Èç¹û¹´Ñ¡“ÆôÓÃC2ÉóºË¸ú×Ù”£¬½«»áÔÚ..MSSQL\Log\Ŀ¼ ......