5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PL/SQLでテストデータをInsertする

Last updated at Posted at 2015-02-03

さくっとある程度の量のテストデータを用意したいときに使うテンプレート。

1.Insertの用意

sql1.sql
/* セッション内のトランザクションをリセット */
rollback;
/* クリーンインサートするためデータクリア */
truncate table tbl1;

begin
 for i in 1..1000 loop
  insert /*+ append */into tbl1 (id, point) values ('test' || to_char(i), i);
 end loop
 commit;
end;
/
quit

「/」+「改行」がないとPL/SQLが実行されないので注意。

2.実行(Windows)

foo.bat
sqlplus user/pass@host @sql1
5
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?