Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 28th, 2005, 06:52 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: India.
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default Select Into statement

hi all

Can i use Select Into statement in Oracle for creating a table?

Thnx

Ashu




  #2 (permalink)  
Old July 28th, 2005, 07:36 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ashu,
Your query is not clear.
Do you want to insert the selected values into a table,if so you can use
Insert into destination_table (col_one,col_two,col_three) values(select col_one,col_two,col_three from source_table)

Regards,
Ram.

  #3 (permalink)  
Old July 28th, 2005, 09:47 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: India.
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

hi Ram

actually i wanna do 2 things,
1) Create Table with same structure and
2) Insert all the rows of frst table into the new table


thnx
Ashu



  #4 (permalink)  
Old July 29th, 2005, 05:25 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ashu,
Create Source table:
create table source_table(colone number(9),coltwo varchar2(9));
Insert some data into the source_table:
   Insert into source_table values(1,A)
   Insert into source_table values(2,B)
   Insert into source_table values(3,C)
   Insert into source_table values(4,D)
Create Destination Table:
Create table Destination_Table(colone number(9),coltwo varchar2(9));
Inserting Source table data into Destination table:
   Insert into Destination_Table values(select colone,coltwo from source_table)

Hope it will helps you.

Regards,
Ram.




  #5 (permalink)  
Old July 29th, 2005, 12:51 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: India.
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

Hi Ram

i also used the same method
but isn't is a way around

wht i m asking is can we create and populate a table as we can do in SQL Server

thnx

Ashu

  #6 (permalink)  
Old July 30th, 2005, 02:15 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ranafsd Send a message via Yahoo to ranafsd
Default

hi ashu!!
try the following statement
create table <t1> as select * from (t2>
t1 table'll create same structure and data as t2

  #7 (permalink)  
Old August 1st, 2005, 07:36 AM
Registered User
 
Join Date: Jul 2005
Location: PE, , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can also use the 'COPY' command from SQL Plus. Very powerful. Here is what the help file says about the 'COPY' command:

usage: COPY FROM <db> TO <db> <opt> <table> { (<cols>) } USING <sel>
  <db> : database string, e.g., scott/tiger@d:chicago-mktg
  <opt> : ONE of the keywords: APPEND, CREATE, INSERT or REPLACE
  <table>: name of the destination table
  <cols> : a comma-separated list of destination column aliases
  <sel> : any valid SQL SELECT statement

  #8 (permalink)  
Old October 9th, 2005, 09:09 AM
Registered User
 
Join Date: Oct 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

to create a new table with the same structure and data of old table use this statement
CREATE TABLE New_Table AS
SELECT * FROM Old_Table;

  #9 (permalink)  
Old October 9th, 2005, 11:30 PM
Authorized User
 
Join Date: Aug 2005
Location: Vathiyur - Kanchipuram, Tamil Nadu, India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
  You can use the same structure for Creating table. There is no problem.

Thanx
Adalarasu

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select statement ??? RinoDM SQL Server 2000 7 June 19th, 2008 08:40 AM
select Statement gregalb SQL Server 2000 3 January 15th, 2008 12:00 AM
select statement help... RinoDM SQL Server 2000 13 January 10th, 2008 08:34 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Select Statement jmss66 Oracle 1 May 27th, 2004 02:31 PM



All times are GMT -4. The time now is 12:48 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.