標籤:oracle 操作
Oracle常用的一些操作,記錄下來:
1.建立資料表空間和使用者的步驟:使用者建立:create user 使用者名稱 identified by "密碼";授權:grant create session to 使用者名稱; grant create table to 使用者名稱; grant create tablespace to 使用者名稱; grant create view to 使用者名稱; 2.資料表空間建立資料表空間(一般建N個存資料的資料表空間和一個索引空間):create tablespace 資料表空間名datafile ‘ 路徑(要先建好路徑)\***.dbf ‘ size *Mtempfile ‘ 路徑\***.dbf ‘ size *Mautoextend on --自動成長--還有一些定義大小的命令,看需要 default storage( initial 100K, next 100k,);例子:建立資料表空間create tablespace DEMOSPACE datafile ‘E:/oracle_tablespaces/DEMOSPACE_TBSPACE.dbf‘ size 1500M autoextend on next 5M maxsize 3000M;刪除資料表空間drop tablespace DEMOSPACE including contents and datafiles3.使用者權限授予使用者使用資料表空間的許可權:alter user 使用者名稱 quota unlimited on 資料表空間;或 alter user 使用者名稱 quota *M on 資料表空間;4.--資料表空間CREATE TABLESPACE sdtDATAFILE ‘F:\tablespace\demo‘ size 800M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; --索引資料表空間CREATE TABLESPACE sdt_IndexDATAFILE ‘F:\tablespace\demo‘ size 512M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; --2.建使用者create user demo identified by demo default tablespace demo; --3.賦權grant connect,resource to demo;grant create any sequence to demo;grant create any table to demo;grant delete any table to demo;grant insert any table to demo;grant select any table to demo;grant unlimited tablespace to demo;grant execute any procedure to demo;grant update any table to demo;grant create any view to demo;5.--匯入匯出命令 ip匯出方式: exp demo/[email protected]:1521/orcl file=f:/f.dmp full=yexp demo/[email protected] file=f:/f.dmp full=yimp demo/[email protected] file=f:/f.dmp full=y ignore=y6.--建立資料鏈create database link ygbgtest_portaltest_link connect to portal identified by portal using ‘(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.104.102)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )‘; select * from [email protected]_portaltest_link; 7.--建立暫存資料表以擷取遠端資料表資料 Create global temporary table temp_ygbg_information on commit preserve rows as select * from [email protected]_portaltest_link;select count(1) from temp_ygbg_information t;select * from temp_ygbg_information;8.--從暫存資料表中將資料插入到目的表中insert into portal_information (id, title, picture_url, status, author_id, author_name, create_time, modify_date, delete_date, view_num, order_flag, summary, type, promulgation_charge, information_source, sort_num, sub_title, is_slidenews) select SEQ_PORTAL_INFORMATION.NEXTVAL, title, picture_url, status, author_id, author_name, create_time, modify_date, delete_date, view_num, order_flag, summary, type, promulgation_charge, information_source, sort_num, sub_title, is_slidenews from temp_ygbg_information t1 where t1.id=3338;
本文出自 “憤怒的蝸牛” 部落格,請務必保留此出處http://yangxianhong.blog.51cto.com/5707396/1561984
Oracle常用操作