ת×Ô£ºhttp://hong9270503.blog.163.com/blog/static/127292320091611319516/
ͨ¹ýSQL*PLUSÎÒÃÇ¿ÉÒÔ¹¹½¨ÓѺõÄÊä³ö£¬Âú×ã¶àÑù»¯Óû§ÐèÇó¡£
¡¡¡¡
±¾Àýͨ¹ý¼òµ¥Ê¾Àý£¬½éÉÜͨ¹ýsql*plusÊä³öxls£¬htmlÁ½ÖÖ¸ñʽÎļþ.
¡¡¡¡ Ê×ÏÈ´´½¨Á½¸ö½Å±¾:
¡¡¡¡
1.main.sql
¡¡¡¡ ÓÃÒÔÉèÖû·¾³£¬µ÷ÓþßÌ幦Äܽű¾
¡¡¡¡ 2.¹¦Äܽű¾-get_tables.sql
¡¡¡¡
ΪʵÏÖ¾ßÌ幦ÄÜÖ®½Å±¾
¡¡¡¡ ͨ¹ýÕâÑùÁ½¸ö½Å±¾¿ÉÒÔ±ÜÃâspoolÖеÄÈßÓàÐÅÏ¢.
¡¡¡¡ ʾÀýÈçÏÂ:
¡¡¡¡
1.main.sql½Å±¾:
[oracle@jumper utl_file]$ more main.sql
set
linesize 200
set term off verify off feedback off pagesize 999
set
markup html on entmap ON spool on preformat off
spool tables.xls
@get_tables.sql
spool
off
exit
¡¡¡¡ 2.get_tables.sql½Å±¾:
[oracle@jumper
utl_file]$ more get_tables.sql
select
owner,table_name,tablespace_name,blocks,last_analyzed
from all_tables
order by 1,2;
¡¡¡¡ 3.Ö´Ðв¢»ñµÃÊä³ö:
[oracle@jumper utl_file]$
sqlplus "/ as sysdba" @main
SQL*Plus: Release 9.2.0.4.0 -
Production on Mon Apr 25 10:30:11 2005
Copyrig ......
ת×Ô£ºhttp://hong9270503.blog.163.com/blog/static/127292320091611319516/
ͨ¹ýSQL*PLUSÎÒÃÇ¿ÉÒÔ¹¹½¨ÓѺõÄÊä³ö£¬Âú×ã¶àÑù»¯Óû§ÐèÇó¡£
¡¡¡¡
±¾Àýͨ¹ý¼òµ¥Ê¾Àý£¬½éÉÜͨ¹ýsql*plusÊä³öxls£¬htmlÁ½ÖÖ¸ñʽÎļþ.
¡¡¡¡ Ê×ÏÈ´´½¨Á½¸ö½Å±¾:
¡¡¡¡
1.main.sql
¡¡¡¡ ÓÃÒÔÉèÖû·¾³£¬µ÷ÓþßÌ幦Äܽű¾
¡¡¡¡ 2.¹¦Äܽű¾-get_tables.sql
¡¡¡¡
ΪʵÏÖ¾ßÌ幦ÄÜÖ®½Å±¾
¡¡¡¡ ͨ¹ýÕâÑùÁ½¸ö½Å±¾¿ÉÒÔ±ÜÃâspoolÖеÄÈßÓàÐÅÏ¢.
¡¡¡¡ ʾÀýÈçÏÂ:
¡¡¡¡
1.main.sql½Å±¾:
[oracle@jumper utl_file]$ more main.sql
set
linesize 200
set term off verify off feedback off pagesize 999
set
markup html on entmap ON spool on preformat off
spool tables.xls
@get_tables.sql
spool
off
exit
¡¡¡¡ 2.get_tables.sql½Å±¾:
[oracle@jumper
utl_file]$ more get_tables.sql
select
owner,table_name,tablespace_name,blocks,last_analyzed
from all_tables
order by 1,2;
¡¡¡¡ 3.Ö´Ðв¢»ñµÃÊä³ö:
[oracle@jumper utl_file]$
sqlplus "/ as sysdba" @main
SQL*Plus: Release 9.2.0.4.0 -
Production on Mon Apr 25 10:30:11 2005
Copyrig ......
¡¾SQL¡¿ÐÐÁÐת»»
http://space.itpub.net/519536/viewspace-609167
Ò»¡¢ÁбäÐÐ
1.´´½¨²âÊÔ±ítest£¬²¢³õʼ»¯ÊµÑéÊý¾Ý
sec@ora10g> create table test (name_id varchar2(10), name varchar2(10));
sec@ora10g> insert into test values ('01','Andy1');
sec@ora10g> insert into test values ('01','Andy2');
sec@ora10g> insert into test values ('01','Andy3');
sec@ora10g> insert into test values ('01','Andy4');
sec@ora10g> insert into test values ('02','Steven1');
sec@ora10g> insert into test values ('02','Steven2');
sec@ora10g> insert into test values ('02','Steven3');
sec@ora10g> insert into test values ('02','Steven4');
sec@ora10g> commit;
2.²é¿´²âÊÔ±íÊý¾Ý
sec@ora10g> select * from test order by name_id;
NAME_ID NAME
---------- ----------------------------------------
01 Andy1
01 Andy4
01 Andy3
......
ºÜÉÙÓÃjoin£¬Õâ´Îѧѧ£¬²¢±¸ÍüÁ½ÆªÎÄÕ£¡
ת×Ô£ºhttp://hcx-2008.javaeye.com/blog/285661
Á¬½Ó²éѯ
ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØÏµÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌØµã£¬Ò²ÊÇËüÇø±ðÓÚÆäËüÀàÐÍÊý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹ØÏµ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚÒ»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû§´øÀ´ºÜ´óµÄÁé»îÐÔ£¬ËûÃÇ¿ÉÒÔÔÚÈκÎʱºòÔö¼ÓеÄÊý¾ÝÀàÐÍ¡£Îª²»Í¬ÊµÌå´´½¨ÐÂµÄ±í£¬¶ûºóͨ¹ýÁ¬½Ó½øÐвéѯ¡£
Á¬½Ó¿ÉÒÔÔÚSELECT Óï¾äµÄfrom×Ó¾ä»òWHERE×Ó¾äÖн¨Á¢£¬ËÆÊǶø·ÇÔÚfrom×Ó¾äÖÐÖ¸³öÁ¬½ÓʱÓÐÖúÓÚ½«Á¬½Ó²Ù×÷ÓëWHERE×Ó¾äÖеÄËÑË÷Ìõ¼þÇø·Ö¿ªÀ´¡£ËùÒÔ£¬ÔÚTransact-SQLÖÐÍÆ¼öʹÓÃÕâÖÖ·½·¨¡£
SQL-92±ê×¼Ëù¶¨ÒåµÄfrom×Ó¾äµÄÁ¬½ÓÓï·¨¸ñʽΪ£º
from join_table join_type join_table
[ON (join_condition)]
ÆäÖÐjoin_tableÖ¸³ö²ÎÓëÁ¬½Ó²Ù×÷µÄ±íÃû£¬Á¬½Ó¿ÉÒÔ¶Ôͬһ¸ö±í²Ù×÷£¬Ò²¿ÉÒÔ¶Ô¶à±í²Ù×÷£¬¶Ôͬһ¸ö±í²Ù×÷µÄÁ¬½ÓÓÖ³Æ×ö×ÔÁ¬½Ó¡£
join_type Ö¸³öÁ¬½ÓÀàÐÍ£¬¿É·ÖΪÈýÖÖ£ºÄÚÁ¬½Ó¡¢ÍâÁ¬½ÓºÍ½»²æÁ¬½Ó¡£ÄÚÁ¬½Ó(INNER JOIN)ʹÓñȽÏÔËËã·û½øÐбí¼äij(Щ)ÁÐÊý¾ ......
1.ÐÞ¸ÄÁÐ
EXEC sp_rename 'TableName.ColumnName','NewColumName'
2.Ôö¼ÓÁÐ
ALTER TABLE TableName ADD ColumnName int --Type In Here
3.ɾ³ýÁÐ
ALTER TABLE TableName DROP Column ColumnName ......
ºÜÔç¾Í²»ÓÃSQLServer 2005ÁË£¬½ñÌìͻȻ½Óµ½¸öÏîÄ¿£¬Ëµ·ÇÓÃSQLServer²»¿É£¬Ã»°ì·¨£¬Ö»ºÃ°Ñ¾ÃÎ¥µÄÀÏÅóÓÑ×°ÉÏÈ¥ÁË£¬Óöµ½ÁËCOM+µÄĿ¼ҪÇó²»ÐеÄÎÊÌ⣬ÒÔǰÕâ¸öÎÊÌâÎÒҲûÓÐ×¢Ò⣬½ñÌìÏë½â¾öϸø´ó»ï¿´¿´¡£
¡¡¡¡½â¾öµÄ·½·¨ÆäʵºÜ¼òµ¥£¬ÈçÏ£º
¡¡¡¡1¡¢¿ª»§MSDTC·þÎñ£º“¿ªÊ¼-ÔËÐД£¬ÊäÈë"cmd"ºó»Ø³µ£¬ÔÚÃüÁîÌáʾÐÐÖÐÊäÈë"msdtc -install"²¢»Ø³µ¡£
¡¡¡¡2¡¢¿ªÆôCOM+ System Application·þÎñ£º“¿ªÊ¼-ÔËÐД£¬ÊäÈë"Services.msc"ºó»Ø³µ£¬´ò¿ª·þÎñºÍÓ¦ÓóÌÐò£¬²¢ÔÚ·þÎñÁбíÀïÃæÕÒµ½"COM+ System Application"£¬Êó±êÓÒ¼üµ¥»÷£¬µã»÷“ÊôÐÔ”£¬È»ºó¸ü¸ÄÆô¶¯·½Ê½Îª“×Ô¶¯”£¬×îºóµã»÷ÏÂÃæµÄ“Æô¶¯”¿ªÆô´Ë·þÎñ¡£
¡¡¡¡¶ÔµÚ2µãµÄÖØÒª²¹³ä£ºÓеÄÈ˻ᷢÏÖ"COM+ System Application"Õâ¸ö·þÎñÎÞ·¨Æô¶¯£¬ÆäʵÔÒòºÜ¼òµ¥£¬Õâ¸ö·þÎñÒÀÀµÓÚÏÂͼËùʾµÄÁíÍâ3¸ö·þÎñ£¬½«Õâ3¸ö·þÎñ¶¼¿ªÆô¾Í¿ÉÒÔÁË£º
......
--¸Ã±í±£´æ½á¹û
create table c(c1 tinyint, c2 tinyint, c3 tinyint, c4 tinyint, c5 tinyint, c6 tinyint, c7 tinyint, c8 tinyint, c9 tinyint, c10 tinyint, c11 tinyint, c12 tinyint, c13 tinyint, c14 tinyint, c15 tinyint, c16 tinyint, c17 tinyint, c18 tinyint, c19 tinyint, c20 tinyint, c21 tinyint, c22 tinyint, c23 tinyint, c24 tinyint, c25 tinyint, c26 tinyint, c27 tinyint, c28 tinyint, c29 tinyint, c30 tinyint, c31 tinyint, c32 tinyint, c33 tinyint, c34 tinyint, c35 tinyint, c36 tinyint, c37 tinyint, c38 tinyint, c39 tinyint, c40 tinyint, c41 tinyint, c42 tinyint, c43 tinyint, c44 tinyint, c45 tinyint, c46 tinyint, c47 tinyint, c48 tinyint, c49 tinyint, c50 tinyint, c51 tinyint, c52 tinyint, c53 tinyint, c54 tinyint, c55 tinyint, c56 tinyint, c57 tinyint, c58 tinyint, c59 tinyint, c60 tinyint, c61 tinyint, c62 tinyint, c63 tinyint, c64 tinyint)
--¸Ã±í×öµÑ¿¨¶û»ý
create table tb(t tinyint)
insert into tb
select 1 union
select 0
--½«tb±í×ö64´ÎµÑ¿¨¶û»ý£¬²úÉúËùÓеĿÉÄÜÀàÐÍ
--¸ù¾Ý¹ÀË㣬 ......