oracle数据库迁移 增大空间,Oracle数据库迁移、创建表空间、创建数据表实例讲解-Oracle...
數據庫遷移
對于數據庫遷移來說,如果源數據庫與目標數據庫版本一致,推薦使用Oracle導入或者pl/sql導入;如果版本不一致,則可以使用sql導入的方式。
創建表空間
create tablespace test datafile 'E:\Database\data\test_data.dbf' size 20M autoextend on next 5M maxsize 500M
test為表空間名稱;datafile ‘E:\Database\data\test_data.dbf’指定表空間的物理文件;size 20M 指定物理文件的大小,autoextend指定當數據量超出物理文件的存儲空間時,自動增加文件的大小;而 on next 5M 則指定每次增長的尺寸是5M;maxsize 500M指定表空間的最大尺寸是500M
修改數據庫的默認表空間
alter database default tablespace test
默認表空間修改為test
表空間的重命名
alter tablespace test rename to test_data
表空間重命名為test_data
刪除表空間
刪除表空間時,必須保證此表空間不再被其他用戶引用
drop tablespace test_data including contents and datafiles
刪除名字是test_data的表空間
創建數據表
create table student
(
studentID Number not null,
studentName varchar2(20),
studentAge number,
status varchar2(3),
version number default 0
)
tablespace users
tablespace users表示將表創建于表空間users中
通過視圖user_tables可以獲得當前用戶所擁有的表信息,如查看student的表空間信息
select table_name ,tablespace_name from user_tables where lower(table_name)='student'
查看表結構(在命令窗口中運行,語句結束必須加;號,按回車鍵執行。)
desc student;
給數據表增加列
alter table student add(class_id number);
一次性增加多個列,其中用逗號分割
修改某列的數據類型
alter table student modify(calss_id varchar2(20))
刪除已有列
alter table student drop column class_id
重命名列
alter table student rename column studentID to id
轉移表空間
alter table student move tablespace users
刪除數據表
drop table studrnt
有時由于約束存在,無法刪除。應執行
drop table student cascade constraints
特殊的數據表dual
dual實際屬于系統用戶sys,具有數據庫基本權限的用戶都可以訪問。
dual提供了一行一列的數據格式,從而使各種表達式、函數運算在以其為數據源時更夠輸出單行單列的形式
select sysdate from dual
獲得當前日期
select 5*4.5+7 result from dual
總結
以上是生活随笔為你收集整理的oracle数据库迁移 增大空间,Oracle数据库迁移、创建表空间、创建数据表实例讲解-Oracle...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 农村留守老年人关爱服务方案3篇
- 下一篇: 好听的宠物小精灵名字772个