SQL> create tablespace my_tb datafile '/u01/oracle/oradata/repdb/my_tbs.dbf' size 100m; Tablespace created.

 SQL> create table my_tab tablespace my_tbs as select * from dba_objects;

why we are using the part " select * from dba_objects" in the query.....

Who is Participating?
Geert GConnect With a Mentor Oracle dbaCommented:
you have 2 different names of tablespace in the 2 commands.

tablespace created: MY_TB
table destination tablespace: MY_TBS

was the intention not the same tablespace  ?
or just a typo ... :)
Presumably to adopt the structure/columns of dba_objects as the basis of the structure of your table my_tbs, and possibly to import any records from dba_objects if there are any present in the table.

Happy New Year!!
DavidSenior Oracle Database AdministratorCommented:
The sys.dba_objects view shows the data dictionary (every database object).  It is a commonly cited set of "random" data.  As your example shows, it's a quick way to populate a test table.  The other advantage is that it gives you a consistent test bed if you need to drop and repopulate the table.
Mark GeerlingsDatabase AdministratorCommented:
Or, are you asking: "Why create a table that is a copy of data that is already available from a view?"  One reason for doing this is for performance.  If you need to retrieve this data multiple times, repeated queries of this table will likely be much faster (and cause many fewer logical block reads) than a query from the view.
walkerdbaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.