oracle子查詢建立資料表與表結構修改

2021-09-12 12:22:03 字數 943 閱讀 5276

create table table_name [column(, column...)] as subquery
例子:

1)將30部門(deptno)員工資訊查詢出來(emp):

select * from emp where deptno=30;
2)將子查詢帶入建立表語句中:

create table emp_30 as(

select * from emp where deptno=30

);

1)新增乙個列

alter table table add

(colunm datatype [default export]

[,column datatype]...

);

2)修改已存在的列,為新列定義預設值

alter table table modify

(colunm datatype [default export]

[,column datatype]...

);

例子:

1)新增新列

alter table  dept30

add (job varchar2(9));

(新增後新列將會成為最後一列)

2)修改列的長度型別及預設值

alter table  dept30

modify (ename varchar2(15));

改變後只影響後來記錄

Oracle資料表建立 查詢 約束等操作

create table stuinfo 建立學員資訊表 stuno char 6 not null stuname varchar 2 not nul,stuage number 3,0 not null 新建一張表複製學員資訊表則是 create table stuinfo2 as select...

建立與管理資料表

create table if not exists 列名 資料型別 not null null default 列預設值 ebgine 儲存引擎例項alter table xs add 獎學金等級 char 10 after 總學分 alter table xs modify 姓名 char 20...

oracle的查詢資料表(五)

判斷null值 當要檢查列中是否包含空值的時候,需要使用is null 或者is not null語句,null通常為空值,空值的意思就是未指定的,不存在的值,不能與空白值相混淆,空白值是乙個村莊的,只是值為空白的值,使用邏輯組合在where子句中除了使用單個布林表示式外,還可以通過使用邏輯條件組合...