Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2005, 06:52 AM
Friend of Wrox
 
Join Date: Oct 2004
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




 
Old July 28th, 2005, 07:36 AM
Authorized User
 
Join Date: Jul 2005
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.

 
Old July 28th, 2005, 09:47 AM
Friend of Wrox
 
Join Date: Oct 2004
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



 
Old July 29th, 2005, 05:25 AM
Authorized User
 
Join Date: Jul 2005
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.




 
Old July 29th, 2005, 12:51 PM
Friend of Wrox
 
Join Date: Oct 2004
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

 
Old July 30th, 2005, 02:15 AM
Registered User
 
Join Date: Jul 2005
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

 
Old August 1st, 2005, 07:36 AM
Registered User
 
Join Date: Jul 2005
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

 
Old October 9th, 2005, 09:09 AM
Registered User
 
Join Date: Oct 2005
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;

 
Old October 9th, 2005, 11:30 PM
Authorized User
 
Join Date: Aug 2005
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






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





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