Oracle 資料庫 使用者與表的操作

2022-04-14 08:11:14 字數 1285 閱讀 9768

一、資料庫、使用者及表的管理建立資料庫:

create database dbname;

刪除資料庫:

drop database dbname;

建立命名空間:

create tablespace tsname; datafile 'c:\tsname.dbf'; size 100m; autoextend on; next 10m;(tsname為表空間名稱,datafile 用於設定物理檔名稱,size 用於設定表空間的初識大小,autoextend on 用於設定自動增長,如果儲存量超過初始大小,則開始自動擴容,next 用於設定擴容的空間大小)

建立新使用者:

create user1 identified by password1

default

tablespace tsname;

使用者賦權:

grant dba to user1;grant connect to user1;

建立新錶:

create table tname(col1 type1 (not

null) [primary key],col2 type2(not null

));根據已有的舊表建立新錶:

select *into newtable from oldtable;

修改表某列列明:

alter table tname rename column c1 to c2;

增加列:

alter table tname add column col;

刪除列:

alter table tname drop column col;

刪除使用者:

drop user username cascade;

二、資料庫資料的操作(匯入及匯出)匯出資料庫中所有資料:

exp user1/password1 file=d:\test.dmp statistics=none;

匯出資料庫中部分表全部資料:

exp user1/password1 file=d:\test.dmp statistics=none tables=(table1,table2,table3...);

匯出資料庫中部分表部分資料:

exp user1/password1 file=d:\test.dmp statistics=none tables=(table1,table2,table3...)query="where rownum <= 1000";

Oracle建立使用者以及備份還原資料庫操作

create the user create user xx identified by default tablespace users temporary tablespace temp profile default password expire grant revoke role priv...

Oracle建立使用者以及備份還原資料庫操作

create the user create user xx identified by default tablespace users temporary tablespace temp profile default password expire grant revoke role priv...

Oracle資料庫之建立表空間與使用者

一 建立表空間 基本語法表述 create tablespace tablespace name datafile datafile spec1 datafile spec2 詳細的create tablespace語法描述請參考 說明 1.tablespace name 指出表空間的名稱。2.da...