0. 登錄數據庫後臺
---- 匿名連接:
sqlplus /nolog
---- 切換到管理員用戶登錄:
conn /as sysdba
也可以一步到位:
sqlplus /as sysdba
1. 創建用戶 和 創建表空間 和 指定表空間給用戶 和 授權用戶權限
---- 查看錶空間路徑(獲取路徑--創建表空間時使用):
select a.*,a.bytes/1024/1024 from dba_data_files a;
---- 創建用戶
create user 用戶名 identified by 密碼;
----創建表空間 xx_space(自定義表空間名稱) /u01/oracle/11g/dbs(表空間路徑)-------
create tablespace xx_space datafile '表空間路徑/xx_data.dbf' size 200m autoextend on next 32m maxsize 4096m extent management local;
----創建臨時表空間 xx_tempspace(自定義臨時表空間名稱)--------
create temporary tablespace xx_tempspace tempfile '表空間路徑/xx_temp_data.dbf' size 50m autoextend on next 10m maxsize 1024m;
----分配表空間和臨時表空間
alter user 用戶名 default tablespace xx_space temporary tablespace xx_tempspace;
----給用戶分配權限
grant create session,create trigger,create table ,create view,create sequence, unlimited tablespace to 用戶名;
--select 字段 1 , 字段 2 , 字段 3 , 表達式 , 函數 , ... --from 表名 --where 條件 --group by 列名 --having 帶組函數的條件 --order by 列名
2. 基本的操作語法
select 字段1,字段2,表達式,函數,...
from 表名
where 條件
group by 列名
having 帶組函數的條件
order by 列名;
---- 內連接 :
表1 join 表2 on 條件
----左連接:
表1 left join 表2 on 條件
----右連接:
表1 right join 表2 on 條件
---- 全外連接:
表1 full outer join 表2 on 條件