
文章插圖
一、Oracle數(shù)據(jù)庫(kù)操作1、創(chuàng)建數(shù)據(jù)庫(kù)
create database databasename
2、刪除數(shù)據(jù)庫(kù)
drop database dbname
3、備份數(shù)據(jù)庫(kù)
完全備份exp demo/demo@orcl buffer=1024 file=d:back.dmp full=y
demo:用戶名、密碼
buffer: 緩存大小
file: 具體的備份文件地址
full: 是否導(dǎo)出全部文件
ignore: 忽略錯(cuò)誤,如果表已經(jīng)存在,則也是覆蓋
將數(shù)據(jù)庫(kù)中system用戶與sys用戶的表導(dǎo)出exp demo/demo@orcl file=d:backup1.dmp owner=(system,sys)
導(dǎo)出指定的表exp demo/demo@orcl file=d:backup2.dmp tables=(teachers,students)
按過(guò)濾條件,導(dǎo)出exp demo/demo@orcl file=d:back.dmp tables=(table1) query=” where filed1 like ‘fg%'”
導(dǎo)出時(shí)可以進(jìn)行壓縮;命令后面 加上 compress=y ;如果需要日志,后面:log=d:log.txt
備份遠(yuǎn)程服務(wù)器的數(shù)據(jù)庫(kù)exp 用戶名/密碼@遠(yuǎn)程的IP:端口/實(shí)例 file=存放的位置:文件名稱.dmp full=y
4、數(shù)據(jù)庫(kù)還原
打開(kāi)cmd直接執(zhí)行如下命令,不用再登陸sqlplus 。
完整還原imp demo/demo@orcl file=d:back.dmp full=y ignore=y log=D:implog.txt
指定log很重要,便于分析錯(cuò)誤進(jìn)行補(bǔ)救 。
導(dǎo)入指定表imp demo/demo@orcl file=d:backup2.dmp tables=(teachers,students)
還原到遠(yuǎn)程服務(wù)器imp 用戶名/密碼@遠(yuǎn)程的IP:端口/實(shí)例 file=存放的位置:文件名稱.dmp full=y
二、Oracle表操作1、創(chuàng)建表
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
根據(jù)已有的表創(chuàng)建新表:
A:select * into table_new from table_old (使用舊表創(chuàng)建新表)
B:create table tab_new as select col1,col2… from tab_old definition only<僅適用于Oracle>
2、刪除表
drop table tabname
3、重命名表
說(shuō)明:alter table 表名 rename to 新表名
eg:alter table tablename rename to newtablename
4、增加字段
說(shuō)明:alter table 表名 add (字段名 字段類型 默認(rèn)值 是否為空);
例:alter table tablename add (ID int);
alter table tablename add (ID varchar2(30) default ‘空’ not null);
5、修改字段
說(shuō)明:alter table 表名 modify (字段名 字段類型 默認(rèn)值 是否為空);
eg:alter table tablename modify (ID number(4));
6、重名字段
說(shuō)明:alter table 表名 rename column 列名 to 新列名 (其中:column是關(guān)鍵字)
eg:alter table tablename rename column ID to newID;
7、刪除字段
說(shuō)明:alter table 表名 drop column 字段名;
eg:alter table tablename drop column ID;
8、添加主鍵
alter table tabname add primary key(col)
9、刪除主鍵
alter table tabname drop primary key(col)
10、創(chuàng)建索引
create [unique] index idxname on tabname(col….)
11、刪除索引
drop index idxname
注:索引是不可更改的,想更改必須刪除重新建 。
12、創(chuàng)建視圖
create view viewname as select statement
13、刪除視圖
drop view viewname
三、Oracle操作數(shù)據(jù)1、數(shù)據(jù)查詢
select <列名> from <表名> [where <查詢條件表達(dá)試>] [order by <排序的列名>[asc或desc]]
2、插入數(shù)據(jù)
insert into 表名 values(所有列的值);
insert into test values(1,’zhangsan’,20);
insert into 表名(列) values(對(duì)應(yīng)的值);
insert into test(id,name) values(2,’lisi’);
3、更新數(shù)據(jù)
update 表 set 列=新的值 [where 條件] –>更新滿足條件的記錄
update test set name=’zhangsan2′ where name=’zhangsan’
update 表 set 列=新的值 –>更新所有的數(shù)據(jù)
update test set age =20;
4、刪除數(shù)據(jù)
以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問(wèn)題,請(qǐng)您及時(shí)就醫(yī)或請(qǐng)專業(yè)人士給予相關(guān)指導(dǎo)!
「愛(ài)刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對(duì)您有所幫助:- 講解oracle建立用戶及授權(quán) 正版oracle授權(quán)購(gòu)買
- 獲取當(dāng)前客戶端IP地址詳解 js獲取客戶端ip地址
- 中國(guó)人離不開(kāi)的五大軟件 中國(guó)人離不開(kāi)的五大軟件你敢卸載那一個(gè)
- 如何使用Oracle數(shù)據(jù)庫(kù) oracle登陸數(shù)據(jù)庫(kù)
- oracle數(shù)據(jù)庫(kù)基礎(chǔ)知識(shí) oracle數(shù)據(jù)庫(kù)類型的文件
- 手機(jī)火狐瀏覽器默認(rèn)下載路徑 火狐瀏覽器卸載不了
- oracle中替換字段內(nèi)容 oracle替換指定字符串字符
- oracle數(shù)據(jù)庫(kù)菜鳥(niǎo)教程 oracle 性能優(yōu)化工具
- win7自帶office卸載方法 office2013卸載不了怎么辦
- 數(shù)據(jù)庫(kù)性能優(yōu)化方法 oracle性能調(diào)優(yōu)總結(jié)
