Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : sql

³£ÓõÄORACLE PL/SQL¹ÜÀíÃüÁîÒ»

Ô­ÎÄ£ºÁõÎä| ³£ÓõÄORACLE PL/SQL¹ÜÀíÃüÁîÒ»
ÊìϤORACLE¹ÜÀíµÄÒ»¶¨¶ÔÕâЩÃüÁî²»»áÄ°Éú£¬²»¹ý¶ÔÓÚÎÒÕâ¸ö¸Õ½Ó´¥ORACLE¹ÜÀíµÄÀ´Ëµ£¬»¹ÊÇÓбØÒª×öϼǼ£¬ÒÔ±ãËæʱ²é¿´¡£
Ò» µÇ¼SQLPLUS
sqlplus Óû§Ãû/ÃÜÂë@Êý¾Ý¿âʵÀý as µÇ¼½ÇÉ«;
Èç:Óû§sys(ÃÜÂëΪ123)ÒÔsysdbaµÄ½ÇÉ«µÇ¼Êý¾Ý¿âORACL£¬ÎÒÃÇ¿ÉÒÔÊäÈ룺sqlplus sys/123@oracl as sysdba;
ÕâÖֵǼ·½Ê½»áÖ±½Ó±©Â¶ÃÜÂ룬Èç¹ûÏëÒþ²ØÃÜÂ룬¿ÉÒÔÔÚ´ËÊ¡ÂÔÃÜÂëµÄÊäÈ룬È磺sqlplus sys@oracl as sysdba;»Ø³µÒÔºóORACLE»á¸ø³öÊäÈëÃÜÂëµÄÌáʾ·û¡£
µÇ¼ÒÔºóÈç¹ûÏëÇл»ÆäËûµÄÓû§£¬¿ÉÒÔÖ±½ÓʹÓÃconnect ÃüÁî,È磺connect user2/password@oracl as sysdba,ͬÉÏÒ»Ñù£¬¿ÉÒÔ½«ÃÜÂë·Ö¿ªÊäÈë¡£
¶þ Í˳öSQLPLUS
quit£»
Èý ´´½¨Óû§
create user Óû§Ãû identified by ÃÜÂë;
È磺´´½¨Óû§CKSP£¬ÃÜÂëΪ123: create user cksp identified by 123;
ËÄ ¸øÓû§·ÖÅä½ÇÉ«»òȨÏÞ
grant *** to ***;
È磺¸ø¸Õ²ÅµÄÓû§·ÖÅä½ÇÉ«DBA:grant dba to cksp;
·ÖÅäcreate table ȨÏÞ£ºgrant
Îå ɾ³ýÓû§
drop user Óû§ [cascade];
ÆäÖÐcascadeÊÇ¿ÉÑ¡µÄ£¬Èç¹ûÊäÈëÁË£¬Ôò±íʾɾ³ý¸ÃÓû§¼°ËùÓÐÊý¾Ý¡£
È磺ɾ³ýÉÏÃæ´´½¨µÄÓû§CKSP¼°ËûµÄËùÓÐÊ ......

³£ÓõÄORACLE PL/SQL¹ÜÀíÃüÁîÒ»

Ô­ÎÄ£ºÁõÎä| ³£ÓõÄORACLE PL/SQL¹ÜÀíÃüÁîÒ»
ÊìϤORACLE¹ÜÀíµÄÒ»¶¨¶ÔÕâЩÃüÁî²»»áÄ°Éú£¬²»¹ý¶ÔÓÚÎÒÕâ¸ö¸Õ½Ó´¥ORACLE¹ÜÀíµÄÀ´Ëµ£¬»¹ÊÇÓбØÒª×öϼǼ£¬ÒÔ±ãËæʱ²é¿´¡£
Ò» µÇ¼SQLPLUS
sqlplus Óû§Ãû/ÃÜÂë@Êý¾Ý¿âʵÀý as µÇ¼½ÇÉ«;
Èç:Óû§sys(ÃÜÂëΪ123)ÒÔsysdbaµÄ½ÇÉ«µÇ¼Êý¾Ý¿âORACL£¬ÎÒÃÇ¿ÉÒÔÊäÈ룺sqlplus sys/123@oracl as sysdba;
ÕâÖֵǼ·½Ê½»áÖ±½Ó±©Â¶ÃÜÂ룬Èç¹ûÏëÒþ²ØÃÜÂ룬¿ÉÒÔÔÚ´ËÊ¡ÂÔÃÜÂëµÄÊäÈ룬È磺sqlplus sys@oracl as sysdba;»Ø³µÒÔºóORACLE»á¸ø³öÊäÈëÃÜÂëµÄÌáʾ·û¡£
µÇ¼ÒÔºóÈç¹ûÏëÇл»ÆäËûµÄÓû§£¬¿ÉÒÔÖ±½ÓʹÓÃconnect ÃüÁî,È磺connect user2/password@oracl as sysdba,ͬÉÏÒ»Ñù£¬¿ÉÒÔ½«ÃÜÂë·Ö¿ªÊäÈë¡£
¶þ Í˳öSQLPLUS
quit£»
Èý ´´½¨Óû§
create user Óû§Ãû identified by ÃÜÂë;
È磺´´½¨Óû§CKSP£¬ÃÜÂëΪ123: create user cksp identified by 123;
ËÄ ¸øÓû§·ÖÅä½ÇÉ«»òȨÏÞ
grant *** to ***;
È磺¸ø¸Õ²ÅµÄÓû§·ÖÅä½ÇÉ«DBA:grant dba to cksp;
·ÖÅäcreate table ȨÏÞ£ºgrant
Îå ɾ³ýÓû§
drop user Óû§ [cascade];
ÆäÖÐcascadeÊÇ¿ÉÑ¡µÄ£¬Èç¹ûÊäÈëÁË£¬Ôò±íʾɾ³ý¸ÃÓû§¼°ËùÓÐÊý¾Ý¡£
È磺ɾ³ýÉÏÃæ´´½¨µÄÓû§CKSP¼°ËûµÄËùÓÐÊ ......

SQLÅжÏ×Ö¶ÎÀàÐÍ

-->Title:Generating test data
-->Author:wufeng4552
-->Date :2009-09-25 09:56:07
if object_id('tb')is not null drop table tb
go
create table tb(ID int,name text)
insert tb select 1,'test'
go
--·½·¨1
select sql_variant_property(ID,'BaseType') from tb
--·½·¨2
select object_name(ID)±íÃû,
       c.name ×Ö¶ÎÃû,
       t.name Êý¾ÝÀàÐÍ,
       c.prec ³¤¶È
from syscolumns c
inner join systypes t
on c.xusertype=t.xusertype
where objectproperty(id,'IsUserTable')=1 and id=object_id('tb') ......

³É¼¨µ¥¡¢Òµ¼¨±íSQL(Ò»¸ö×ݱí±äºá±í Ò»¸öÓÿª´°º¯Êý)

 Ô­Ê¼±í£º
name            course              score
-----------------------------------------
ÕÅÈý            ÓïÎÄ                80
ÕÅÈý            Êýѧ                75
ÕÅÈý            ÍâÓï                60
ÀîËÄ            ÓïÎÄ                90
ÀîËÄ            Êýѧ                85
ÀîËÄ            ÍâÓï                70
ÍõÎå            ÓïÎÄ                95
ÍõÎå            Êýѧ&nb ......

½ñÌì×°ÁËOracle SQL developer

ÏÂÔغó½âѹËõ¾ÍÄÜÖ±½ÓʹÓÃÁË£¬µ«ÊÇÊÇÖÐÎĵģ¬×ÖÌåÏÔʾµÄ²»ÊǺܺã¬ÓÚÊÇÕÒµ½ÁË»»Ó¢Îĵİ취£º
ÓÉÓÚ1.5°üº¬Á˶àÓïÑÔ½çÃæµÄÖ§³Ö£¬µ«ÊÇËüÊÇͨ¹ýJVMÀ´±æÈÏϵͳÓïÑԵģ¬ËùÒÔµ±ÄãµÄϵͳÓïÑÔΪÖÐÎĵÄʱºò£¬Ëü»áʹÓÃÖÐÎĽçÃæ¡£²»¹ýËüµÄÖÐÎÄ·­Òë²¢²»ÍêÕû£¬¼ÓÉÏĬÈϽçÃæ×ÖÌå̫С£¬Ê¹ÓÃÖÐÎĻῴ×ŷdz£ÄÑÊÜ¡£Èç¹ûÏëʹÓÃÓ¢ÎĽçÃ棬ÐèÒªÐÞ¸ÄÏÂJVM²ÎÊý¡£
ÕÒµ½sqldeveloper\bin\sqldeveloper.conf,¼ÓÈë
AddVMOption -Duser.language=en
AddVMOption -Duser.country=US
ÆäËüµÄÐéÄâ²ÎÊý²ÎÊýÒ²¿ÉÒÔͨ¹ýÕâÖÖ·½Ê½´«µÝ¡£ ......

½ñÌì×°ÁËOracle SQL developer

ÏÂÔغó½âѹËõ¾ÍÄÜÖ±½ÓʹÓÃÁË£¬µ«ÊÇÊÇÖÐÎĵģ¬×ÖÌåÏÔʾµÄ²»ÊǺܺã¬ÓÚÊÇÕÒµ½ÁË»»Ó¢Îĵİ취£º
ÓÉÓÚ1.5°üº¬Á˶àÓïÑÔ½çÃæµÄÖ§³Ö£¬µ«ÊÇËüÊÇͨ¹ýJVMÀ´±æÈÏϵͳÓïÑԵģ¬ËùÒÔµ±ÄãµÄϵͳÓïÑÔΪÖÐÎĵÄʱºò£¬Ëü»áʹÓÃÖÐÎĽçÃæ¡£²»¹ýËüµÄÖÐÎÄ·­Òë²¢²»ÍêÕû£¬¼ÓÉÏĬÈϽçÃæ×ÖÌå̫С£¬Ê¹ÓÃÖÐÎĻῴ×ŷdz£ÄÑÊÜ¡£Èç¹ûÏëʹÓÃÓ¢ÎĽçÃ棬ÐèÒªÐÞ¸ÄÏÂJVM²ÎÊý¡£
ÕÒµ½sqldeveloper\bin\sqldeveloper.conf,¼ÓÈë
AddVMOption -Duser.language=en
AddVMOption -Duser.country=US
ÆäËüµÄÐéÄâ²ÎÊý²ÎÊýÒ²¿ÉÒÔͨ¹ýÕâÖÖ·½Ê½´«µÝ¡£ ......

SQL SERVER»ñÈ¡±íµÄ¿Õ¼ä·Ö²¼Çé¿ö

/********************************
¹¦ÄÜ£º»ñÈ¡±íµÄ¿Õ¼ä·Ö²¼Çé¿ö
**********************************/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
create table  tablespaceinfo                         --´´½¨½á¹û´æ´¢±í
              (nameinfo varchar(50) ,    --ΪÆäÇëÇó¿Õ¼äʹÓÃÐÅÏ¢µÄ±íÃû¡£
               rowsinfo int ,     --±íÖÐÏÖÓеÄÐÐÊý¡£
        reserved varchar(20) ,    --±í±£ÁôµÄ¿Õ¼ä×ÜÁ¿¡£
               datainfo varchar(20)  ,    --±íÖеÄÊý¾ÝËùʹÓõĿռäÁ¿¡£
& ......

ÅúÁ¿Éú³ÉͬÀàÐÍsqlÓï¾äµÄ½Å±¾

--ÔÚÈÕ³£Î¬»¤£¬¿ª·¢Öг£Óöµ½Ð´Ò»ÏµÁнṹÀàÐ͵ÄsqlÓï¾ä£¬ºÜ·³ºÜÀÛÆäʵ¿ÉÒÔ
--ÀûÓÃSQL*PLUS»·¾³ÃüÁî  Éú³É½Å±¾Îļþ
        set heading off   --¹Ø±ÕÁеıêÌâ
        set feedback off  --¹Ø±Õ·´À¡ÐÅÏ¢
        spool c:\aa.txt   --»º³åдÎļþc:\aa.txt
        em£º
        select 'insert into dept values ('||deptno||','||''''||dname||''''||','||''''||loc||''''||');' from dept;   --Ö´ÐÐselectÓï¾ä
        spool off  --¹Ø±Õ»º³å
--ÎÒÓöµ½¹ýµÄ2¸öÓ¦ÓÃ
--µ¼³öij¸öÓû§ÏÂËùÓеĽ¨±íÓï¾ä£¨Ò²¿É½èÖúÆäËû¹¤¾ßʵÏÖ£¬casestudio£¬powerdesignµÈ£©
SELECT 'SELECT TO_CHAR(DBMS_METADATA.GET_DDL(''TABLE'','''||TABLE_NAME||'''))'||' from dual;'
from ALL_TABLES where owner='SYSTEM';
--killµ±Ç°²¿·Ösession
select username,'alter system kill session '||''''|| ......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [707] [708] [709] [710] 711 [712] [713] [714] [715] [716]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ