oracle資料庫雜記(典型例子 常用)

2021-09-01 10:09:47 字數 1234 閱讀 4126

1.-----------------左連線(m表中的記錄是一定存在的,在a表中可能沒有)---------

[align=left]select * from mmm m,aaa a where m.member_id = a.member_id(+) and m.member_id = 'xxmguandao01'[/align][align=left]select * from mmm m left join aaa a on m.member_id = a.member_id where m.member_id = 'xxmguandao01'[/align]2,[align=left]從乙個資料庫中複製表到裡乙個資料據 [/align]

create public database link bb_dev_dev

connect to 使用者名稱

identified by 123

using '資料庫連線池';

************從乙個庫中向另乙個資料庫中同步資料************************************

create table cc as select * from bb@bb_dev;

3.(分割槽)分組完成後取當前組中的第二條記錄

select cc.*

from (select row_number() over(partition by memo order by gmt_create desc) rno, c.*

from abc c)cc

where rno = 2

資料庫中沒1000條提交一次

declare

n_count integer := 0;

cursor cur_1 is select * from 源表;

begin

for icur_1 in cur_1 loop

insert into 目標表 values (icur_1.col1,icur_1.col2, ……icur_1.coln);

n_count := n_count + 1;

if n_count >= 1000 then

commit;

n_count := 0;

end if;

end loop;

commit;

exception

when others then

rollback;

end;

/

資料庫雜記

第一講 關係 單一的資料結構 關係 邏輯結構 二維表 域 某串集合 笛卡爾積 給定的一組域,域中不同的元素組成新的不同的域。從d1中隨意拿取乙個元祖與d2中隨意拿出乙個元祖進行組合,那麼所有的組合就是d1d2的 笛卡爾積 笛卡爾積是一種全部的可能,但現實中的情況可能只是笛卡爾積的乙個真子集 元祖 笛...

資料庫雜記

目錄 設計關聯式資料庫時,遵從不同的規範要求,設計出合理的關係型資料庫,這些不同的規範要求被稱為不同的正規化,各種正規化呈遞次規範,越高的正規化資料庫冗餘越小。目前關聯式資料庫有六種正規化 第一正規化 1nf 第二正規化 2nf 第三正規化 3nf 巴斯 科德正規化 bcnf 第四正規化 4nf 和...

資料庫典型題目

工廠 工廠編號,廠名,位址 主碼是工廠編號 職工 工號,姓名,工廠編號,聘期,工資 主碼是工號,外碼是工廠編號 產品 產品編號,產品名,規格 主碼是產品編號 生產關係 產品編號,工廠編號,計畫數量 主碼是 產品編號,工廠編號 外碼是產品編號 工廠編號 select a anmae from a wh...