ORACLE向表中插入1到20,按照往常,第一反应会想到写个小程序来完成此功能。
SQL> create table tc(id int);
Table created.
SQL> insert into tc SELECT LEVEL AS ID FROM dual CONNECT BY LEVEL <= 20;
20 rows created.
SQL> commit;
Commit complete.
SQL> select * from tc;
ID
----------
1
2
3
4
5
6
7
8
9
10
11
ID
----------
12
13
14
15
16
17
18
19
20
20 rows selected
.
本文介绍了一种在Oracle数据库中快速向表内插入从1到20的整数序列的方法,利用了CONNECT BY LEVEL功能,避免了编写额外的小程序。
9313

被折叠的 条评论
为什么被折叠?



