Oracle 的基本操作(2)

2021-09-12 03:19:06 字數 1445 閱讀 9281

--建立使用者及授權

create user a_hr identified by 123456;

grant dba to a_hr;

create user a_oe identified by 123456;

grant dba to a_oe;

drop table stock_received --刪除該錶

--建立 stock_received 表,有 stock_id 、stock_date 和 cost 列。

--建立 myseq 序列,該序列的起始值為 1000,每次查詢增加10,直到該序列達到 1100,然後重新從 1000 開始

create table stock_received(

stock_id number not null,

stock_date date not null,

cost number not null

)create sequence myseq

minvalue 1000

maxvalue 1100

start with 1000

increment by 10

cache 10

cycle;

select myseq.nextval from dual;

--建立公有同義詞 p_stock_received ,並通過 a_oe 訪問

create public synonym p_stock_received for a_hr.stock_received;

grant select on p_stock_received to a_oe;

select * from p_stock_received;--可以通過a_oe訪問

select * from a_hr.stock_received;--可以通過a_oe訪問

--將 stock_date 建立 3 個範圍分割槽

create table stock_received2

partition by range(stock_date)

(partition part2 values less than (to_date('2012/01/01','yyyy/mm/dd')),

partition part3 values less than (to_date('2013/01/01','yyyy/mm/dd')),

partition part4 values less than (to_date('2014/01/01','yyyy/mm/dd'))

) as select * from stock_received;

--在 stock_id 列上建立唯一索引

create unique index idx_stock_id on stock_received(stock_id);

Oracle 的基本操作(2)

建立使用者及授權 create user a hr identified by 123456 grant dba to a hr create user a oe identified by 123456 grant dba to a oe drop table stock received 刪除該...

oracle的基本操作

1 建立表空間 一般建n個存資料的表空間和乙個索引空間 create tablespace 表空間名 datafile 路徑 要先建好路徑 dbf size m tempfile 路徑 dbf size m autoextend on 自動增長 還有一些定義大小的命令,看需要 default sto...

oracle的基本操作

create tablespace itheima datafile c itheima.dbf size 100m autoextend on next 10m 刪除表空間 drop tablespace itheima create user itheima identified by ithe...