oracle資料庫的操作語句

2021-10-05 14:20:33 字數 2574 閱讀 1462

//備份

create table [備份名] as select * from [表名]

;//恢復

truncate table org_group;

//此為清空表操作,慎用

insert into org_group select * from [備份名]

;

//備份表

//oracle使用者終端執行:

exp [使用者名稱]

/[密碼] tables=

[表一]

,[表二] file=

/home/oracle/table.dmp

//恢復表

//oracle使用者終端執行:

imp [使用者名稱]

/[密碼] grants=y commit=y full=y ignore=y file=

/home/oracle/table.dmp

create table tablename (age int

,name string ……)

select * from user_tab_columns t where t.table_name=

'表名'

;

truncate table [表名]

;

drop table [表名]

;

alter table [老表名] rename to [新錶名]

;

alter table [表名] add  [新增字段]

[字段型別]

;

alter table [表名] modify [表字段]

[新型別]

default

'[預設填充的值]'

;

alter table [表名] rename column [老表字段] to [新表字段]

;

alter table [表名] drop column  [要刪除的表字段]

;

update [表名] set [欄位名]

=[新值] where [條件]

;

insert into [表名]

([欄位1],

[欄位2

]) values (

[值1],[值2])

;

insert into [表名]  values (

[值1]

,[值2],

[值3]..

....

);

delete from [表名] where [字段]

=[值]

;

select distinct [字段]  from [表名]

;

select * from [表名] where [欄位名] is not null;
//字串沒有限制,主要是用來標識查詢到的字段資訊

select '[字串1]'

||[欄位名1]||

'[字串2]'

||[欄位名2]||

'[字串3]'

||[欄位名3

] as [新建的欄位名,用來放前面的查詢來的資訊] from [表名]

;

update t_mp_material_news_item a

set is_deleted =

1where exists (select 1

from t_mp_material_news b

where b.id=a.news_id and to_char

(b.create_time,

'yyyy-mm-dd'

)<

'2019-01-01'

)//查詢驗證

select a.create_time,b.is_deleted

from

t_mp_material_news_item b ,t_mp_material_news a

where b.news_id=a.id and to_char

(a.create_time,

'yyyy-mm-dd'

)>

'2019-01-01'

模糊查詢

<

if test=

"item.title != null and item.title != ''"

>

and title like concat

(concat

('%',#)

,'%'

)>

ORACLE資料庫操作基本語句

username password server as sysdba sysoper eg.system password or connect sys password as sysdbashow user dba users desc dba users 展示表結構 select usernam...

Oracle 資料庫常用操作語句大全

文件摘自 一 oracle資料庫操作 1 建立資料庫 create database databasename 2 刪除資料庫 drop database dbname 3 備份資料庫 exp demo demo orcl buffer 1024 file d back.dmp full y dem...

Oracle 資料庫常用操作語句大全

轉 一 oracle資料庫操作 1 建立資料庫 create database databasename 2 刪除資料庫 drop database dbname 3 備份資料庫 exp demo demo orcl buffer 1024 file d back.dmp full y demo 使...