Oracle資料庫基本操作

來源:互聯網
上載者:User

標籤:

--建立資料表空間(一個資料表空間可以有多個使用者)--
create tablespace demo
datafile ‘D:\oracle\oradata\junchen\PLATFORM\demo.dbf‘
size 50m
autoextend on;

--建立使用者,並且關聯資料表空間--
create user demo
identified by dd
default tablespace demo;

--給使用者指派許可權--
grant connect,resource to 使用者名稱;
grant create view to 使用者名稱;--建立視圖許可權
grant create sequence to 使用者名稱;--建立序列許可權
grant sysdba to 使用者名稱;--管理員權限

grant create session,create any table,create any view,create any index,create
any procedure,alter any table,alter any procedure,drop any table,drop any view,drop any index,drop any procedure,
select any table,insert any table,update any table,delete any table,dba to demo;--所有許可權



--修改資料檔案--
--查看資料檔案路徑--
select file_id,bytes,file_name from dba_data_files;
--重新指定尺寸為20M--
alter database datafile ‘資料檔案路徑‘ resize 20m;



--修改表所屬資料表空間:
alter table 表名 move tablespace "資料表空間名稱"

--修改表索引所屬資料表空間:
alter index 索引名 rebuild tablespace "資料表空間名稱"



匯出資料庫
exp userid=jsmall/[email protected]/orcl file=e:/demo.dmp
exp userid=DD_APP/[email protected]/prosc file=e:/DD_APP.dmp
exp userid=DD_EFLOW/[email protected]/prosc file=e:/DD_EFLOW.dmp
exp userid=AUTH/[email protected]/prosc file=e:/AUTH.dmp
exp userid=SB_PORTAL/[email protected]/prosc file=e:/SB_PORTAL.dmp

匯入資料庫
imp system/[email protected] file=f:\data.DMP full=y
解決oracle“這些對象由xxx匯出,而不是目前使用者”方案
imp userid=demo/[email protected]/prosc file=E:/demo.dmp ignore=y fromuser=demo touser=demo
imp userid=DD_APP/[email protected]/prosc file=E:/DD_APP.dmp ignore=y fromuser=DD_APP touser=DD_APP
imp userid=DD_EFLOW/[email protected]/prosc file=E:/DD_EFLOW.dmp ignore=y fromuser=DD_EFLOW touser=DD_EFLOW
imp userid=AUTH/[email protected]/prosc file=E:/AUTH.dmp ignore=y fromuser=AUTH touser=AUTH
imp userid=SB_PORTAL/[email protected]/prosc file=E:/SB_PORTAL.dmp ignore=y fromuser=SB_PORTAL touser=SB_PORTAL




--刪除--
--1、刪除表及序列等--
--2、刪除使用者--
drop user 使用者名稱;
--3、刪除資料表空間--
drop tablespace 使用者名稱_tablespace;

分頁:
select * from (
       select row_.*, rownum rownum_ from (
              查詢sql
       ) row_
) where rownum_ <= 結束行 and rownum_ > 起始行;
查詢總行數:
select count(1) from (查詢SQL) tmp_count;

Oracle資料庫基本操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.