Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:04:51+00:00 2026-06-15T01:04:51+00:00

I have table TABLE_INFO with columns TNAME, CNAME, DTYPE, COLCOMMENT I need to create

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:04:52+00:00Added an answer on June 15, 2026 at 1:04 am

    Oh, I confused.

    This is a code for schema:

    CREATE TABLE TABLE_INFO
    (
        TNAME        VARCHAR2 (30)
       ,CNAME        VARCHAR2 (30)
       ,DTYPE        VARCHAR2 (30)
       ,COLCOMMENT   VARCHAR2 (100)
    );
    
    INSERT INTO TABLE_INFO VALUES ('Employee','Emp_ID','NUMBER','Employee ID');
    INSERT INTO TABLE_INFO VALUES ('Employee','Emp_Nm','VARCHAR','Employee Name');
    INSERT INTO TABLE_INFO VALUES ('Employee','Emp_Sal','NUMBER','Employee Salary');
    INSERT INTO TABLE_INFO VALUES ('Job','Job_ID','NUMBER','Job ID');
    INSERT INTO TABLE_INFO VALUES ('Job','Job_Nm','VARCHAR','Job Name');
    INSERT INTO TABLE_INFO VALUES ('Department','Dept_ID','VARCHAR','Department ID');
    INSERT INTO TABLE_INFO VALUES ('Department','Dept_Nm','VARCHAR','Department Name');
    

    And, this is a code for execution:

    -- FOR TABLE CREATION
    SELECT 
     CASE WHEN RNO = 1 THEN 'CREATE TABLE '||T1.TNAME||' ( ' ELSE '    ' END ||
     T2.CNAME || ' ' || T2.DTYPE ||
     CASE WHEN CNT = RNO THEN ');' ELSE ',' END AS SQLTEXT
      FROM (  SELECT TNAME
                    ,COUNT (1) CNT
                FROM TABLE_INFO
            GROUP BY TNAME) T1
          ,(SELECT ROW_NUMBER () OVER (PARTITION BY TNAME ORDER BY CNAME) RNO
                  ,X.*
              FROM TABLE_INFO X) T2
     WHERE T1.TNAME = T2.TNAME
    ORDER BY T1.TNAME, T2.RNO;
    
    -- FOR COMMENT CREATION
    SELECT 'COMMENT ON TABLE ' || TNAME || '.' || CNAME || ' IS ''' || COLCOMMENT || ''';' AS SQLTEXT
      FROM TABLE_INFO;
    

    You could find the result at here

    NOTE: I used ROW_NUMBER () function at Oracle only. please be aware of that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in Oracle 10g that contains some information as follows: SQL>
I have a table in sql server 2005 which holds an ip range and
I have a table which contains 3 columns, fname Lname and description . I
I have this SQL Table: TABLE: Info COLUMNS:| Name | Value --------|----------|------------------ ROW: |
I have a table, InnoDB, with columns id(int), name(varchar) and info(text). I need to
Currently have a table .. and need to start adding new data columns to
I have a table like this: CREATE TABLE book_info ( book_id VARCHAR(32) not null,
I have a table schema which is essentially a bunch of transaction info with
I have table named 'Dictionary' with columns as follow: ID bigint TYPE varchar (200)
I currently have a table that is 17 columns wide and has 30 records.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.