I have table TABLE_INFO with columns TNAME, CNAME, DTYPE, COLCOMMENT
I need to create a SQL script in Oracle SQL Developer, which creates new table with table name from column TNAME, columns from CNAME, datatype of columns from DTYPE and column comment from COLCOMMENT
How can I do this?
For example table TABLE_INFO has following data:
|TNAME | CNAME | DTYPE | Comment |
1|Employee | Emp_ID | NUMBER | Employee ID |
2|Employee | Emp_Nm| VARCHAR | Employee Name |
3|Job | Job_ID | NUMBER | Job ID | etc.
I need to write many CREATE TABLE statements like :
CREATE TABLE EMLOYEE
(EMP ID NUMBER,
Emp_Nm VARCHAR)
COMMENT ON COLUMN EMP_ID is ''Employee ID''
COMMENT ON COLUMN EMP_NM is ''Employee NAME''
for each TNAME
Oh, I confused.
This is a code for schema:
And, this is a code for execution:
You could find the result at here
NOTE: I used
ROW_NUMBER ()function at Oracle only. please be aware of that.