Creating Duplicate Table From Existing Table [duplicate] - oracle

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
SELECT INTO using Oracle
I have one table in my oracle database. I want to create one table with another name, but containing same data. How to achieve this ?

Use this query to create the new table with the values from existing table
CREATE TABLE New_Table_name AS SELECT * FROM Existing_table_Name;
Now you can get all the values from existing table into newly created table.

Related

ORACLE ORA-00933 when using CREATE as SELECT [duplicate]

This question already has an answer here:
Creating a table from a query using a different tablespace (Oracle SQL)
(1 answer)
Closed 5 years ago.
I tried to simply create a table with the structure of another table to sync them contents later.
When is use "CREATE as SELECT", it just returns the error
ORA-00933 "SQL command not properly ended"
As mentioned in the link, the syntax should be OK.
https://www.techonthenet.com/oracle/tables/create_table2.php
Both tables should be stored in the same user scheme.
The only difference is the added user scheme and tablespace.
CREATE TABLE "MYUSER.TABLE_B"
as (SELECT * FROM "MYUSER.TABLE_A")
TABLESPACE "SANDBOX" ;
I don't have Oracle database with me now, but I am sure, you can use like this-
CREATE TABLE "MYUSER.TABLE_B"
TABLESPACE "SANDBOX"
AS
SELECT *
FROM "MYUSER.TABLE_A";

How to get new and old value of column in statement level trigger in oracle? [duplicate]

This question already has answers here:
Oracle trigger after insert or delete
(3 answers)
Closed 6 years ago.
I have a table whose name is TestTable.
Create Table TestTable(ID number,Name nvarchar2(200))
I want to write a trigger. It's a statement level trigger. My question is:
How to get new and old value of column in statement level trigger in oracle?
I can't use a row level trigger because I need to select row count from TestTable in trigger.
As comments said you can't have access to :new and :old on statement level. How can you define row values if trigger that see whole statement?
Please use compound trigger (Documentation and Example). There you can write section that is statement level and another one for each row. Count you'll get in statement level and access to :old and :new you'll have on for each row section

Generate upgrade script to ALTER TABLE based on CREATE TABLE statement in Oracle [duplicate]

This question already has answers here:
Automated Oracle Schema Migration Tool [closed]
(5 answers)
Closed 7 years ago.
Is it possible in Oracle to generate a bunch of ALTER TABLE statements based on existing table in schema plus CREATE TABLE statement with newer definition of that table?
Let's say I have a schema with some previous version of an application. I have an installation script for newest version of the application. The script creates all tables and sequences from scratch performing CREATE TABLE (and probably CREATE SEQUENCE) statements.
I'd like to update the schema to the newest version of the application without loosing any data (e.g. without performing DROP TABLE).
Is it possible with using of standard Oracle 11gR2 or third party components?
You can try CORT : www.cort.tech
https://github.com/cort-master/cort
It's free
You can create a procedure in PLSQL to:
create new table when it not exists in new DB
alter table when it exists, feeding it with ALL_TAB_COLUMNS

Oracle procedure to update multiple values in single instance [duplicate]

This question already has answers here:
displaying Oracle table's column names
(2 answers)
Closed 8 years ago.
Is there a procedure I can run to search all tables to see to search a particular column? I need to update a particular string present in that column in all tables whereever applicable. There are too many tables to open each one and do a find on the value(s) I'm looking for.
This should help you find the tables which contain your columns:
SELECT TABLE_NAME
FROM USER_TAB_COLUMNS
WHERE COLUMN_NAME='your_column_name';
After that you can execute updates for each table that you have.
I didn't understand your question completely, so I hope this helps you ;)

inserting records from one table to another in oracle [duplicate]

This question already has answers here:
How to do INSERT into a table records extracted from another table
(9 answers)
Closed 9 years ago.
My problem is, i have two table namely enq_tab and feed_back_tab. i need to insert some columns from enq_tab into feed_back_tab and some columns are from a webpage ie, a jsp...
ex: enq_tab: enq_id,name,email,mobile,address,enq_date are columns;
feed_back_tab:enq_id,name,email,mobile,address,enq_date,feed_back,comments,suggestions are columns
here i will get the feed_back,comments, suggestions from the JSP , and remaining columns from the enq_tab based on enq_id, which already present in database.
anybody help me with some suggestions..
Thank in advance..
I think you can do this way.
insert into table1(COL1,COL2,COL3,COL4)
select col1,col2,jspvaribalevalue1,jspvariblevalue2 from table2

Resources