exp/impツールカラム影響

 

(5.6)
(5.7)
(8)

--確認事項
ダンプ取得後、カラム追加したテーブルへダンプからリストアできるか


--テーブル作成
drop table tab1;
create table tab1(col1 int);
alter table tab1 add constraint cons1 primary key(col11);
insert into tab1 values(1);
select * from tab1;


--データのみダンプ取得
\! mysqldump -uroot -p -t test tab1 > tab1.dmp

--カラム追加
alter table tab1 add col2 int;


--トランケート
truncate table tab1;


--データのみリストア
source tab1.dmp

--結果
ERROR 1136 (21S01): Column count doesn't match value count at row 1
→リストア不可

(12cR1)
(12cR2)
(18c)

--確認事項
ダンプ取得後、カラム追加したテーブルへダンプからリストアできるか


--テーブル作成
drop table tab1 purge;
create table tab1(col1 int);
create unique index ind1 on tab1(col1);
alter table tab1 add constraint cons1 primary key(col1) using index ind1;

insert into tab1 values(1);
commit;
select * from tab1;


--データのみダンプ取得
!expdp test/test directory=ORA_DIR dumpfile=tab1.dmp logfile=tab1.exp.log tables=tab1 content=data_only reuse_dumpfiles=y

--カラム追加
alter table tab1 add(col2 int);


--トランケート
truncate table tab1;


--データのみリストア
!impdp test/test directory=ORA_DIR dumpfile=tab1.dmp logfile=tab1.imp.log tables=tab1 content=data_only


--結果
→リストア可

 

(19c)

--確認事項
ダンプ取得後、カラム追加したテーブルへダンプからリストアできるか


--テーブル作成
drop table tab1 purge;
create table tab1(col1 int);
create unique index ind1 on tab1(col1);
alter table tab1 add constraint cons1 primary key(col1) using index ind1;

insert into tab1 values(1);
commit;
select * from tab1;


--データのみダンプ取得
!expdp test/test@pdb1 directory=ORA_DIR dumpfile=tab1.dmp logfile=tab1.exp.log tables=tab1 content=data_only reuse_dumpfiles=y

--カラム追加
alter table tab1 add(col2 int);


--トランケート
truncate table tab1;


--データのみリストア
!impdp test/test@pdb1 directory=ORA_DIR dumpfile=tab1.dmp logfile=tab1.imp.log tables=tab1 content=data_only


--結果
→リストア可

(9.4)
(9.6)
(10)
(11)
(12)

--確認事項
ダンプ取得後、カラム追加したテーブルへダンプからリストアできるか


--テーブル作成
drop table tab1;
create table tab1(col1 int);
create unique index ind1 on tab1(col1);
alter table tab1 add constraint cons1 primary key using index ind1;

insert into tab1 values(1);
select * from public.tab1;

--データのみダンプ取得
\! pg_dump -Fp -a -t tab1 test > tab1.dmp

--カラム追加
alter table tab1 add col2 int;


--トランケート
truncate table tab1;


--データのみリストア
\i tab1.dmp

 

--結果
→リストア可

 

--確認事項
ダンプ取得後、カラム追加したテーブルへダンプからリストアできるか


--テーブル作成
drop table tab1;
create table tab1(col1 int not null);
create unique index ind1 on tab1(col1);
alter table tab1 add constraint cons1 primary key(col1);


insert into tab1 values(1);
select * from tab1;


-- フォーマットファイルの作成
bcp test.dbo.tab1 format nul -f "C:\tab1.fmt" -T -c -t,


--データのみダンプ取得

bcp test.dbo.tab1 out "C:\tab1.dmp"  -T -c -t,

 

--カラム追加
alter table tab1 add col2 int;


--トランケート
truncate table tab1;


--データのみリストア
--フォーマットファイルを使用しない場合

bcp test.dbo.tab1 in "C:\tab1.dmp"  -T -c -t,

BCP データファイル中で予期しない EOF が検出されました。

--データのみリストア
--フォーマットファイルを使用する場合
bcp test.dbo.tab1 in "C:\tab1.dmp"  -T  -t, -f "C:\tab1.fmt"

→リストア可