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

³£ÓÃ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. ¸´ÖƱ


Ïà¹ØÎĵµ£º

SQL Ñ­»·

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ЧÂʵØϵÄÔ­Òò


[MySQLÓÅ»¯] -- ÈçºÎ²éÕÒSQLЧÂʵØϵÄÔ­Òò
ʱ¼ä:2010-2-28À´Ô´:HaCMS¿ªÔ´ÉçÇø ×÷Õß:chusong
²éѯµ½Ð§ÂÊµÍµÄ SQL Óï¾ä ºó£¬¿ÉÒÔͨ¹ý EXPLAIN »òÕß DESC ÃüÁî»ñÈ¡ MySQL ÈçºÎÖ´ÐÐ SELECT Óï¾äµÄÐÅÏ¢£¬°üÀ¨ÔÚ SELECT Óï¾äÖ´Ðйý³ÌÖбíÈçºÎÁ¬½ÓºÍÁ¬½ÓµÄ˳Ðò£¬±ÈÈçÎÒÃÇÏë¼ÆËã 2006 ÄêËùÓй«Ë¾µÄÏúÊ۶ÐèÒª¹ØÁª sales ......

Sql ¸ù¾ÝÃû³ÆÌÞ³ýÖظ´Êý¾Ý¡¢¸ù¾Ýid·µ»Ø×îеÄ

select *
  from (
        select soft.NETMODEL,
                soft.softname,
                soft.softid ......

SQL²éѯËÙ¶ÈÂýµÄÔ­Òò

1¡¢Ã»ÓÐË÷Òý»òÕßûÓÐÓõ½Ë÷Òý(ÕâÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐòÉè¼ÆµÄȱÏÝ)
¡¡¡¡2¡¢I/OÍÌÍÂÁ¿Ð¡£¬ÐγÉÁËÆ¿¾±Ð§Ó¦¡£
¡¡¡¡3¡¢Ã»Óд´½¨¼ÆËãÁе¼Ö²éѯ²»ÓÅ»¯¡£
¡¡¡¡4¡¢ÄÚ´æ²»×ã
¡¡¡¡5¡¢ÍøÂçËÙ¶ÈÂý
¡¡¡¡6¡¢²éѯ³öµÄÊý¾ÝÁ¿¹ý´ó(¿ÉÒÔ²ÉÓöà´Î²éѯ£¬ÆäËûµÄ·½·¨½µµÍÊý¾ÝÁ¿)
¡¡¡¡7¡¢Ëø»òÕßËÀËø(ÕâÒ²ÊDzéѯÂý×î³£¼ûµÄÎÊÌ⣬ÊdzÌÐ ......

SQL Server 2005/2008 °²È«¼à¿Ø£¨´ýÐø£©

-- ²é¿´µ±Ç°dbµÄµÇ½
select * from sys.sql_logins
-- ÉóºËµÇ½Êý¾Ý¿âµÄÓû§
sql server managerment studioÖУ¬ÓÒ¼üµã¿ª·þÎñÆ÷µÄÊôÐÔ£¬ÔÚ°²È«ÐÔҳǩÖУ¬ Ñ¡ÖÐÉóºË“³É¹¦ºÍʧ°ÜµÄµÇ½”£¬ËùÓеǽ¶¼»áÔÚ..MSSQL\Log\ERRORLOGÖмǼһÌõ¼Ç¼¡£
Èç¹û¹´Ñ¡“ÆôÓÃC2ÉóºË¸ú×Ù”£¬½«»áÔÚ..MSSQL\Log\Ŀ¼ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ