Oracle 創建表空間和表
查找oracle11安裝目錄
我的電腦右擊—管理—服務—orcleserviceOrcl—雙擊—可看路徑
(d:\oraclexe\app\oracle\product\11.2.0\server\bin\ORACLE.EXE XE)
sqlplus創建表空間和用戶
(輸入用戶名sys as sysdba【是默認的系統用戶】,密碼是安裝orcle時的密碼)
C:\Users\Administrator>sqlplus
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jul 19 13:21:30 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
--1、創建表空間:
--格式: create tablespace 表間名 datafile '數據文件名' size 表空間大小
--(*數據文件名 包含全路徑, 表空間大小 500M 表是 500兆)
SQL> create tablespace data_test datafile 'D:\oraclexe\app\oracle\oradata\XE\data_1.dbf' size 500M;
Tablespace created.
--2、建好tablespace, 就可以建用戶了 創建用戶並指定表空間
--格式: create user 用戶名 identified by 密碼 default tablespace 表空間表;
--(*我們創建一個用戶名爲 study,密碼爲 study, 缺少表空間爲 data_test -這是在第二步建好的.)
--(*缺省表空間表示 用戶study今後的數據如果沒有專門指出,其數據就保存在 data_test中, 也就是保存在對應的物理文件 D:\oraclexe\app\oracle\oradata\XE\data_1.dbf中)
SQL> create user data0719 identified by data0719 default tablespace data_test;
User created.
--3. 授權給新用戶
----表示把 connect,resource權限授予data0709用戶
----表示把 dba權限授予給 data0709
SQL> grant connect,resource to data0719;
Grant succeeded.
SQL> grant dba to data0719;
Grant succeeded.
SQL>
---創建表
create table test2(
id varchar2(10) primary key,
name varchar2(100) not null
);