Creating a (demo)table

Often I need to create a table just for demonstration puposes, and this table needs to be filled up with data. The question for this post is…..: How to generate rows, preferrably a distinct number.

So what I do? If the table has to be created yet:

create table <table_name> as 
  with <generator_name> as (select rownum l from dual connect by level< <number of rows>)
  select [l <column_name>,....]  from <generator_name>;

Or if the table allready exists:

insert into <table> 
  with engine as (select rownum l from dual connect by level < <number of rows>)
  select [<column>,....] from engine; 

Did I think of this myself….no….I’m not that inventive. I “borrowed” this method from Jonathan Lewis

If you generate (demo) tables in a differrent way…please show me.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *