Skip to content

Commit 1c869b5

Browse files
authored
Create value-constructor.sql
1 parent f55ea6c commit 1c869b5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
REM Script in 23c: value-constructor.sql
2+
3+
-- use it in the FROM clause to generate rows
4+
SELECT *
5+
FROM (VALUES (1,'SCOTT'),
6+
(2,'SMITH'),
7+
(3,'JOHN')
8+
) t1 (employee_id, first_name);
9+
10+
-- with clause
11+
with CCCP (c1,c2) as (
12+
values (1, 'SCOTT'), (2, 'SMITH'), (3, 'JOHN'))
13+
select * from cccp;
14+
15+
16+
-- create a table and cast it to get the correct length of the column
17+
drop table if exists cccp;
18+
19+
create table cccp
20+
as
21+
SELECT *
22+
FROM (VALUES (1,'SCOTT'),
23+
(2,cast('SMITH' as VARCHAR2(30))),
24+
(3,'JOHN')
25+
) t1 (employeed_id,first_name)
26+
where 1=2;
27+
28+
desc cccp
29+
30+
- use it to add 3 rows
31+
insert into cccp (EMPLOYEED_ID, FIRST_NAME)
32+
values (1,'SCOTT'),
33+
(2,'SMITH'),
34+
(3,'JOHN');
35+
commit;
36+
37+
select * from cccp;

0 commit comments

Comments
 (0)