1. 程式人生 > >OracleXENuiv,資料庫建立使用者,表空間,

OracleXENuiv,資料庫建立使用者,表空間,

目標資料夾: F:\oracle\
'Oracle 資料庫監聽程式' 的埠: 1521
'用於 Microsoft Transaction Server 的 Oracle 服務' 的埠: 2030
HTTP 監聽程式的埠: 8080

SYSTEM/root,
SYS/root,

{--
system是資料庫內建的一個普通管理員,你手工建立的任何使用者在被授予dba角色後都跟這個使用者差不多。
sys用資料庫的超級使用者,資料庫內很多重要的東西(資料字典表、內建包、靜態資料字典檢視等)都屬於這個使用者,sys使用者必須以sysdba身份登入。
以上就是2個使用者的區別。
另外你說的,system使用者as sysdba登入時和sys一樣的問題:
system使用者以sysdba身份登入時就是sys,準確地說,任何使用者以sysdba身份登入時都是sys,這一點,你登陸後執行show user可以驗證。
--}


建立使用者 ym/ym, create user ym identified by ym; 
授權:grant create session to ym;  
            grant create table to  ym;  
            grant create tablespace to  ym;  
            grant create view to ym;  
修改使用者密碼:alter user ym identified by root;


現在以ym使用者登入


在ym使用者建立表空間:
create tablespace TestSpace   
datafile 'F:/Oracle/app/oracle/TestSpace.dbf'   
size 10M   
autoextend on next 5M maxsize 300M;

刪除表空間  //drop tablespace TestSpace including contents and datafiles  


SYSTEM使用者登入授予使用者ym使用表空間的許可權:  
alter user ym quota unlimited on TestSpace; 

//授權
agrant connect,resource to ym;  
grant create any sequence to ym;  
grant create any table to ym;  
grant delete any table to ym;  
grant insert any table to ym;  
grant select any table to ym;  
grant unlimited tablespace to ym;  
grant execute any procedure to ym;  
grant update any table to ym;  
grant create any view to ym;  


建立表
create table ym.FBP_FISCAL_PERIOD
(
  creation_date     NUMBER(14) not null,
  created_by        NUMBER(38) not null,
  last_update_login NUMBER(38),
  enabled_flag      CHAR(1) default 'Y' not null,
  last_update_date  NUMBER(14),
  last_updated_by   NUMBER(38) not null,
  org_id            NUMBER(38) not null,
  period_id         NUMBER(38) not null,
  fiscal_year       NUMBER(4) not null,
  period_state      CHAR(1) not null,
  period_code       VARCHAR2(128) not null,
  period_name       VARCHAR2(256) not null,
  strart_time       NUMBER(14) not null,
  end_time          NUMBER(14) not null
)
commit;


comment on table ym.FBP_FISCAL_PERIOD
  is '會計期間';
-- Add comments to the columns 
comment on column ym.FBP_FISCAL_PERIOD.creation_date
  is '建立日期';
comment on column ym.FBP_FISCAL_PERIOD.created_by
  is '建立者';
comment on column ym.FBP_FISCAL_PERIOD.last_update_login
  is '最後修改時的登入ID';
comment on column ym.FBP_FISCAL_PERIOD.enabled_flag
  is '有效標識';
comment on column ym.FBP_FISCAL_PERIOD.last_update_date
  is '最後更新日期';
comment on column ym.FBP_FISCAL_PERIOD.last_updated_by
  is '最後更新者';
comment on column ym.FBP_FISCAL_PERIOD.org_id
  is '機構ID';
comment on column ym.FBP_FISCAL_PERIOD.period_id
  is '期間ID';
comment on column ym.FBP_FISCAL_PERIOD.fiscal_year
  is '會計年度';
comment on column ym.FBP_FISCAL_PERIOD.period_state
  is '期間狀態';
comment on column ym.FBP_FISCAL_PERIOD.period_code
  is '期號';
comment on column ym.FBP_FISCAL_PERIOD.period_name
  is '期名';
comment on column ym.FBP_FISCAL_PERIOD.strart_time
  is '開始時間';
comment on column ym.FBP_FISCAL_PERIOD.end_time
  is '結束時間';
  
-- Create/Recreate primary, unique and foreign key constraints 
alter table ym.FBP_FISCAL_PERIOD
add constraint PK_FBP_FISCAL_PERIOD primary key (PERIOD_ID);
  
select table_name,tablespace_name from user_tables where table_name='FBP_FISCAL_PERIOD';
此時發現 此表建在了SYSTEM表空間;遷移到TestSpace
alter table FBP_FISCAL_PERIOD move tablespace TestSpace