网站黄色在线观看视频,男人和女人操逼有免费的视频吗2018高清,91熟女丨老女人丨高潮丰满,丝袜高潮流白浆潮喷在线播放

中國站

中國站

國際版

聯(lián)系我們

400-002-9968

售前咨詢

售后服務(wù)

注冊 登錄

博客 > Oracle數(shù)據(jù)庫知識(shí):Oracle數(shù)據(jù)庫常用語句大全

Oracle數(shù)據(jù)庫知識(shí):Oracle數(shù)據(jù)庫常用語句大全

  • 標(biāo)簽:
  • Oracle數(shù)據(jù)庫
  • Oracle
  • Oracle語句
  • Oracle命令

瀏覽量:1424次評(píng)論:0次

作者:銳成網(wǎng)絡(luò)整理時(shí)間:2024-06-21 16:10:29

Oracle數(shù)據(jù)庫作為對象關(guān)系數(shù)據(jù)庫管理系統(tǒng),相較于MySQL這種輕量級(jí)數(shù)據(jù)庫管理系統(tǒng),有著功能強(qiáng)大且全面的特點(diǎn),廣泛應(yīng)用于金融、政府、制造業(yè)等大型企業(yè)中。為了更好地理解和掌握Oracle數(shù)據(jù)庫,本文匯總了Oracle數(shù)據(jù)庫常用語句,以下是相關(guān)內(nèi)容。

Oracle數(shù)據(jù)庫知識(shí):Oracle數(shù)據(jù)庫常用語句大全

Oracle數(shù)據(jù)庫操作命令

1、創(chuàng)建數(shù)據(jù)庫

create database databasename

2、刪除數(shù)據(jù)庫

drop database dbname

3、數(shù)據(jù)庫備份

完全備份

exp demo/demo@orcl buffer=1024 file=d:\back.dmp full=y
demo:用戶名、密碼
buffer: 緩存大小
file: 具體的備份文件地址
full: 是否導(dǎo)出全部文件
ignore: 忽略錯(cuò)誤,如果表已經(jīng)存在,則也是覆蓋

將數(shù)據(jù)庫中system用戶與sys用戶的表導(dǎo)出

exp demo/demo@orcl file=d:\backup\1.dmp owner=(system,sys)

導(dǎo)出指定的表

exp demo/demo@orcl file=d:\backup2.dmp tables=(teachers,students)

按過濾條件,導(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ù)庫

exp 用戶名/密碼@遠(yuǎn)程的IP:端口/實(shí)例 file=存放的位置:\文件名稱.dmp full=y

4、數(shù)據(jù)庫還原

打開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)建新表:

select * into table_new from table_old --使用舊表創(chuàng)建新表

create table tab_new as select col1,col2… from tab_old definition only<僅適用于oracle>

2、刪除表

drop table tabname

3、重命名表

alter table 原表名 rename to 新表名

4、增加字段

語法:
alter table 表名 add (字段名 字段類型 默認(rèn)值 是否為空);
例如:
alter table tablename add (ID varchar2(30) default '空' not null);

5、修改字段

語法:
alter table 表名 modify (字段名 字段類型 默認(rèn)值 是否為空);
例如:
alter table tablename modify (ID number(4));

6、重名字段

語法:
alter table 表名 rename column 列名 to 新列名 --其中:column是關(guān)鍵字
例如:
alter table tablename rename column ID to newID;

7、刪除字段

語法:
alter table 表名 drop column 字段名;
例如:
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 視圖名 as select statement

13、刪除視圖

drop view viewname

Oracle常用操作命令

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(對應(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ù)

delete from 表名 where 條件 --刪除滿足條件的記錄
delete from test where id = 1;
delete from test -->刪除所有
commit; -->提交數(shù)據(jù)
rollback; -->回滾數(shù)據(jù)
--delete方式可以恢復(fù)刪除的數(shù)據(jù),但是提交了,就沒辦法了 delete刪除的時(shí)候,會(huì)記錄日志 刪除會(huì)很慢
truncate table 表名
--刪除所有數(shù)據(jù),不會(huì)影響表結(jié)構(gòu),不會(huì)記錄日志,數(shù)據(jù)不能恢復(fù),刪除得很快
drop table 表名
--刪除所有數(shù)據(jù),包括表結(jié)構(gòu)一并刪除,不會(huì)記錄日志,數(shù)據(jù)不能恢復(fù),刪除得很快

5、數(shù)據(jù)復(fù)制

表數(shù)據(jù)復(fù)制

insert into table1 (select * from table2);

復(fù)制表結(jié)構(gòu)

create table table1 select * from table2 where 1>1;

復(fù)制表結(jié)構(gòu)和數(shù)據(jù)

create table table1 select * from table2;

復(fù)制指定字段

create table table1 as select id, name from table2 where 1>1;

數(shù)據(jù)庫復(fù)制命令

如果目標(biāo)表存在

select * from 目標(biāo)表 from 原表 where 1=0 --只復(fù)雜表結(jié)構(gòu)

select * from 目標(biāo)表 from 原表 --復(fù)制表結(jié)構(gòu)和數(shù)據(jù)

如果目標(biāo)表不存在

create table 目標(biāo)表 as 
select * from 原表 where 1=0 --只復(fù)制表結(jié)構(gòu)

create table 目標(biāo)表 as 
select * from 原表 --復(fù)制表結(jié)構(gòu)和數(shù)據(jù)

以上就是關(guān)于Oracle數(shù)據(jù)庫常用語句大全的全部內(nèi)容了,僅供大家參考。

重要聲明:本文來自SQL數(shù)據(jù)庫開發(fā),有部分增減,經(jīng)授權(quán)轉(zhuǎn)載,版權(quán)歸原作者所有,不代表銳成觀點(diǎn),轉(zhuǎn)載的目的在于傳遞更多知識(shí)和信息。

我的評(píng)論

還未登錄?點(diǎn)擊登錄

微信掃碼溝通
微信掃碼溝通

微信掃碼溝通

AI
return head