Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> create table .............as select statement

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: create table .............as select statement
 vineet  Posted: Jul 26, 2007 06:25:59 AM

 Total Post: 23
 Joined: Feb, 2006






 hi everybody.
i have a table user1(user_id,pass).
now i want to create a table user2 as:
create table user2(u_id,p_wd) as select * from user1.
can i do so.
thanks

 Nehru
Posted: Jul 26, 2007 07:07:01 AM  

 Total Post: 46
 Joined: Jul, 2007






 
Hi Vineet,

You can create a table similar to existing table with the following statemet
" CREATE TABLE EMP1 AS SELECT * FROM EMP WHERE 1=2 "
This give you the Structure of the existing table not the data

If you want data also then go for this
"CREATE TABLE EMP1 AS SELECT * FROM EMP "

If table already exist then you want only inserting the data from the existing table then go for this:
"INSERT INTO EMP1 SELECT *FROM EMP;"

Take Care

Bye
Kiran

 Ramesh Joyisa
Posted: Aug 07, 2007 05:22:57 AM  

 Total Post: 246
 Joined: Aug, 2007






 
Dear Vineet,
It is possible to create table with the script
create table user2(u_id,p_wd) as select * from user1.

You can create tables with the different column names but the data type must be same so you cannot mension the data types in the script

 RAJNISH
Posted: Sep 04, 2007 06:51:49 AM  

 Total Post: 92
 Joined: Jan, 2007






 
yes you can create table2 but when you creating like this
crea tebale tab2 as select * from tab1 your tab2 table beccome constraints free it means whatever constraints are defined with your tab1 whereas tab2 become without constraints.

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar357
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software