您好,登錄后才能下訂單哦!
Sql代碼
create table test(
id varchar2(10),
age number
);
Sql代碼
create table
as
select * from test group by id;
Sql代碼
drop table test;--刪除表結(jié)構(gòu)和表數(shù)據(jù)
Sql代碼
truncate table test;--清空數(shù)據(jù)表數(shù)據(jù),沒(méi)有返回余地
delete from test;---清空數(shù)據(jù)表數(shù)據(jù),有返回余地
5、添加字段下載
Sql代碼
alter table test add (
name varchar2(10),
interest varchar2(20)
);
Sql代碼
alter table test drop name;
7.1更新一條數(shù)據(jù)
Sql代碼
update test t
set t.id='001'
where t.id is not null;
commit;
7.2從其他表更新多條數(shù)據(jù)
Sql代碼 下載
update test t set t.name=(
select tm.name
from test_common tm
where t.id=tm.id
);
commit;
--備注:update數(shù)據(jù)時(shí),最好將update子查詢中的sql單獨(dú)建表,提高更新速度。
7.3在PL/SQL中查詢完數(shù)據(jù)直接進(jìn)入編輯模式更改數(shù)據(jù)
Sql代碼
select * from test for update;
--備注:更新操作執(zhí)行完,要鎖上數(shù)據(jù)表,同時(shí)執(zhí)行commit提交操作
8、查詢數(shù)據(jù)
Sql代碼
select * from test;
Sql代碼 下載
select count(0) from test;
--備注:count(0)或者其他數(shù)字比count(*)更加節(jié)省數(shù)據(jù)庫(kù)資源,高效快捷
10.1插入一條數(shù)據(jù)中的多個(gè)字段
Sql代碼
insert into test (C1,C2) values(1,'技術(shù)部');
Sql代碼
insert into test(C1,C2) select C1,C2 from test_common;
commit;
10.2插入多條數(shù)據(jù)
Sql代碼
insert into test(
id,
name,
age
)
select
id,
name,
age
from test_common;
commit;
--備注:1、插入多條數(shù)據(jù)時(shí),insert into語(yǔ)句后面沒(méi)有values,直接拼接數(shù)據(jù)查詢語(yǔ)句;2、在oracle中對(duì)數(shù)據(jù)表進(jìn)行了insert、update、delete等操作后,要執(zhí)行commit提交,否則在系統(tǒng)處是禁止操作數(shù)據(jù)庫(kù)的,因?yàn)榇藭r(shí)數(shù)據(jù)庫(kù)已經(jīng)被鎖死,這是數(shù)據(jù)庫(kù)為了防止多人同時(shí)修改數(shù)據(jù)庫(kù)數(shù)據(jù)造成混亂的一種防范機(jī)制。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。