SQL & PL/SQL :: Copy Into Same Table / Recursive Rename Of Duplicates

May 11, 2011

In MS Windows, if I copy a file and paste it into the same folder, I get a copy with the text 'Copy of' in front of the file name. If I paste it again, I get another copy with a different version number.

E.g.
sqlnet.log
Copy of sqlnet.log
Copy (1) of sqlnet.log
Copy (2) of sqlnet.log

I was wondering if I could copy existing rows into a table and do the same thing?

So, for example if I had this table:

create table tst_srch (srch_is varchar(100), user_name varchar(100), srch_name varchar(100));

insert into tst_srch values (1,'USER1','SRCHA');
insert into tst_srch values (2,'USER1','SRCHB');
insert into tst_srch values (3,'USER1','SRCHC');
insert into tst_srch values (4,'USER1','SRCHD');
insert into tst_srch values (5,'USER2','SRCHC');
insert into tst_srch values (6,'USER2','SRCHD');
insert into tst_srch values (7,'USER2','SRCHD_1');

Could I write a procedure like copy_searches('USER1','USER2') that would copy all USER1's searches to USER2 - including renaming any duplicates.

So it would create these new rows:

8,USER2,SRCHA
9,USER2,SRCHB
10,USER2,SRCHC_1
11,USER2,SRCHD_2

I've looked at various insert statements, merge and match statements and exception handling in procedures .

View 6 Replies


ADVERTISEMENT

Copy And Rename An Oracle Database - (without Export / Import)

Oct 21, 2011

I inherit a backup procedure described in

[URL]......

I ask if this procedure works on Oracle Database 10g R2. I have a Oracle DB 10g r2 on Linux machine and I want to copy it to a windows Oracle DB 10g r2, or if it not works to another Linux machine.

View 2 Replies View Related

SQL & PL/SQL :: RENAME Table In Oracle 8i?

Nov 21, 2011

how to rename table in oracle 8i ?

ALTER TABLE olname RENAME TO nwname;

Above command is not working.

View 2 Replies View Related

SQL & PL/SQL :: Recursive Table Query?

May 5, 2013

I have the following table structure...............

Main_Head table name

main_head_id ,pk
head_desc,
head_id ,
sub_head_id

keys
col table ref col
sub_head_id main_head head_id

the table is recursive table self join
-----------------------------------------
now i want to write the query which return all head_desc which have same head_id

View 12 Replies View Related

Server Administration :: Rename A Partitioned Table?

Mar 21, 2007

i want to rename a table that has partitions.

alter table
testora.oldtablename
rename to
testora.newtablename;

ORA-14048: a partition maintenance operation may not be combined with other operations

View 2 Replies View Related

SQL & PL/SQL :: Unable To Rename A Column For Original Table?

Feb 14, 2012

i am not able to rename a column for original table, once i create a new one with Create table as select i can rename the new table column, but not the original one

SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 14 13:10:10 2012

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> show user
USER is "WEBSYSTEMD6"
SQL> alter table cbe rename column tnum to tnum_old;
alter table cbe rename column tnum to tnum_old
*
ERROR at line 1:
ORA-00900: invalid SQL statement

SQL> create table cbe_test as select * from cbe;

Table created.

SQL> alter table cbe_test rename column tnum to tnum_old;

Table altered.

SQL>

View 12 Replies View Related

Server Utilities :: Rename Table While Using Datapump Import?

Mar 18, 2013

I have a Datapump Export File which was created in Schema mode.

I have to import the tabelles in a new database where a have to use the REMAP SCHEMA Parameter.

Additionally I would like to add a prefix to tablenames.

For example:

original tablename: THE_TABLE
Name after import: IMP_THE_TABLE

Is there a way to add a prefix while using Datapump Import?

View 5 Replies View Related

SQL & PL/SQL :: Delete Duplicates From Table Without Using Rowid?

Mar 30, 2010

I am trying to delete duplicates from table without using rowid.

here is data:-

create table test(col1 number(3),col2 varchar2(20));
insert into test values(100,'rocky');
insert into test values(100,'rocky');

[Code]....

I know i am perfoming dml on view. IT wont allow me to perform DML on view which contain columns with expression. IS there any way to delete duplicates without using rowid?

View 36 Replies View Related

PL/SQL :: Writing A Query To Delete Duplicates From A Table

Aug 16, 2012

I have data some thing like this.

NO NAME LOC SAL
------------------------------------------------------------------
1 A HYD 100
2 B BGL 200
1 A HYD 200
1 A HYD 150

I want to delete duplicate records (group by no,name,loc) but only max(qty) record should be retained. So I need output like this.

NO NAME LOC SAL
------------------------------------------------------------------
1 A HYD 200
2 B BGL 200

View 3 Replies View Related

Multiple Table Query Returning Duplicates With Wrong Values

Oct 20, 2012

These are the tables I'm working with:

SQL> desc custinfo;
Name Null? Type
----------------------------------------- -------- ----------------------------
CUSTID VARCHAR2(4)
CUSTNAME VARCHAR2(18)
CUSTADR VARCHAR2(12)
CUSTCITY VARCHAR2(10)
CUSTSTATE CHAR(2)
CUSTZIP VARCHAR2(5)
CAPACITY NUMBER(3)
HOUSECODE VARCHAR2(2)
[code]...

I don't understand why the custid is the same for each customer, and why it's selecting every customer and not just those with more than 150 gallons ordered.

For this one use the oil tables that you set up and use a subquery. Select the minimum average fall use from the house table. Then show all customers whose number of gallons delivered times two is greater than the minimum.

View 4 Replies View Related

Performance Tuning :: Remove Duplicates From Table Using Criteria Giving In Statement

Jun 3, 2011

I am running the following delete query and it has been running for over 2hrs:

delete from dw.ACCOUNT_FACT
where rowid in
(select rowid from DW.ACCOUNT_FACT
minus
select max(rowid) from DW.ACCOUNT_FACT

[Code]..

Here is the explan plain result:

explain plan for delete from dw.ACCOUNT_FACT
where rowid in
(select rowid from DW.ACCOUNT_FACT
minus
select max(rowid) from DW.ACCOUNT_FACT
group by CRTORD_FIPS_CD, LAST_PAYMENT_DT, ORDER_NUM,

[Code]....

PLAN_TABLE_OUTPUT

Plan hash value: 611392786

----------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 2604G| 260T| | 9018K (91)| 30:03:37 |
| 1 | DELETE | ACCOUNT_FACT | | | | | |
|* 2 | HASH JOIN | | 2604G| 260T| 369M|

[Code].....

Predicate Information (identified by operation id):
---------------------------------------------------

2 - access(ROWID="$kkqu_col_1")

I have all constraints disabled. How do I make this delete finish faster? We're trying to remove duplicates from this table using the criteria giving in the statement.

View 16 Replies View Related

Export/Import/SQL Loader :: Use Export And Then Rename Table?

Jan 12, 2013

oracle 11g.2 ASM with RAC under RHEL 5

we have 2 table same structure one of them is empty and the pther one is contain data the vendor do the insert as select but i found he is wrong due to there duplicated ,now i want to use export and then rename the table and then import but i need with export do a condition

exp user/pass tables=MTR_EPPC_CALLED_DATA file=MTR_EPPC_CALLED_DATA.dmp query="where callstarttime >=to_date('01122012','ddmmyyyy')
and callstarttime <=to_date('31122012','ddmmyyyy')"

but it's seem the query take one condition how can i use this above condition in export ???also my friend say there is way to insert with rowid is this possible ??

View 2 Replies View Related

SQL & PL/SQL :: Copy Data From Table A To B?

Apr 30, 2010

i could copy data from tableA to tableB with the scenario below

1) Currently we have no unique key / primary key defined on both of this tables, due to the nature of data, so insert/update will not work
2) We cant truncate/insert as user will be accessing this tables when the copying process takes place, so we dont want to end up having a scenario where the table does not contain data at a certain time

Will materialize view full refresh work in refreshing a table so we could avoid the problem faced in point 1 & 2.

View 7 Replies View Related

SQL & PL/SQL :: Copy Data From One Table To Another

Feb 11, 2013

I have two tables namely PERSON and WIFE. I want to make WIFE's data available in PERSON table while keeping entries of WIFE maintained and at the same time adding some the values of PERSON against the data of wife.

PERSON Table
PK NAME ADDRESS IS_MARRIED
1 John ab city Y
2 Varvatos cd town N
3 Smith ef town Y
4 Henry gh city Y
5 Lynda gh city Y

WIFE table

PK PERSON_ID (FK) NAME
1 1 Alice
2 3 Rosy
3 4 Lynda

Now i want to copy data of WIFE table into PERSON table like this PERSON table

PK NAME ADDRESS IS_MARRIED
1 John ab city Y
2 Varvatos cd town N
3 Smith ef town Y
4 Henry gh city Y
5 Lynda gh city Y
6 Alice ab city Y
7 Rosy ef town Y

As in the given example you might have noticed that ADDRESS of wife is same as of her spouse and same goes for IS_MARRIED column. Moreover, the PK is also not duplicated. How to go about this?

Another important factor is Lynda already exits in PERSON table, therefore, i certainly don't want to duplicate her entry.

View 8 Replies View Related

SQL & PL/SQL :: Copy Value In Column To Another Table?

May 21, 2006

Is it possible to copy a value in a column from a table into another column in another table using the select statement.

Example: I want to copy the arrival date from the guest table to date_charge in the charges table.

CREATE TABLE GUEST
(ROOM_NUMBER VARCHAR2(2),
DATE_ARRIVAL DATE DEFAULT SYSDATE NOT NULL);
CREATE TABLE CHARGES
(ROOM_NUMBER VARCHAR2(2),
DATE_CHARGE DATE default Sysdate);

[code]....

View 6 Replies View Related

SQL & PL/SQL :: Trigger To Copy Data From One To Another Table

Jun 28, 2010

1. I am inserting a value to a table.through uploading the csv file to the DB table using apex.

2. After the data get inserted into the table(parent),my data should be copied to the another table with some conditions .

3. Is it possible to write a trigger to insert statement from selecting the values from another table.

View 5 Replies View Related

SQL & PL/SQL :: Copy Single Column From One Table To Another?

May 27, 2010

How can i copy a single column from one table to another. Table 1 has a column with data in it, table 2 has the column but is empty, i want to copy data for a single column from table1 to table 2. By the way these table have multiple columns.

View 8 Replies View Related

SQL & PL/SQL :: Copy Data And Constraints From One Table To Another

Dec 20, 2011

how to copy data and constraints from one table to another table

View 8 Replies View Related

How To Create Exact Copy Of A Table

Nov 24, 2012

I must admit my "google skills" have failed me and it is possible that I might be missing something obvious here but allow me to explain.

If I have a table that is populated/accessed by a typical OLTP application such that over time the data in the table may become "fragmented".

I know that is a very controversial term I used but that is not the question here. A simple way to describe the state of the table might be that the table has always been populated with lots of small INSERTs, modified with lots of small UPDATEs and data has been deleted in small DELETEs.

This has meant that the data is neither closely stored in data blocks nor is in any particular order (so there are some empty blocks under HWM).

Now my question is how do I create exact copy of this table and its indexes AS THEY EXIST AT THE MOMENT that includes

1) its data
2) its constraints/indexes etc.
3) its storage parameters
4) data stored in EXACTLY same manner as in original table.

To avoid complications, the table in question is just a normal heap table without any partitioning involved. While

CREATE TABLE AS SELECT (or CREATE TABLE followed by INSERT) will take care of points (1) to (3) above, it will not achieve point (4) above.

View 11 Replies View Related

Copy Data From One Field (varchar) To Another Within A Table

Oct 5, 2010

i have a table COLOR having alphanumeric fields i.e Color Description & Color Ref. i want to copy the values from Color Description to Color Ref.

what will the select statement for this?

View 9 Replies View Related

Oracle Triggers - Copy Data From One Table To Other

Jul 9, 2008

Triggers for oracle database. What I am trying to do is copy original data from one table to another table prior to an update, insert, or delete occurring. Basically we are trying to keep a transactional history, with out having to restore the data. Here is what I have created to date, however it is not executing consistently.

CREATE OR REPLACE TRIGGER DATA_COPY BEFORE
INSERT
OR DELETE
OR UPDATE ON "DB1"."TABLE_1"
[code].......

View 10 Replies View Related

SQL & PL/SQL :: Copy Data Of One Partition Completely To Another Table

Nov 16, 2010

I have 2 tables with same no of column and range partition based on date.At the end of month i want to copy the data of one table to another table.Instead of copy the data i want to copy the data of one partition completely to another table partition ..

View 2 Replies View Related

Automated Script To Copy Data From One Table To Another Every Night?

Feb 27, 2012

i have a table with 15 coulums and containing millions of rows which is being updated everyday.Now i have created a similar report table with only the coulums i need to report on from the main table.what plsql script or if there is any better alternative do i need to write to copy the data from the coulums i need from the main table to the new report table. the new report table will be be updated every 01:00am with the data coming from the main table and the update is automated.

View 3 Replies View Related

Create A Copy Of Missions Table Called AM_X_442_2

Jan 22, 2009

My solution to the following question update 10 rows. It should update only 6 records. Create a copy of the missions table called AM_X_442_2. For missions on this table that meet the following criteria:

1. within the 10 most recent missions
2. length of the first word of the mission code_name exceeds 7 characters

Change the security level to the highest security level found in missions of the same type.

UPDATE
AM_X_442_2 am
SET
am.SECURITY_LEVEL =
(
SELECT
MAX(amx.SECURITY_LEVEL)
FROM
AM_X_442_2 am
INNER JOIN
AM_X_442_2 amx
[code]....

View 2 Replies View Related

SQL & PL/SQL :: How To Copy Constraints (primary / Foreign Key / Indexes) To A Table

Mar 11, 2011

I have created table as below

create table emp_temp as select * from emp;

the table is created, but the constraints are not copied. Is there any way to copy all the constraints.

View 3 Replies View Related

Forms :: How To Copy Values From One Table To Another Using When-Button-Pressed Trigger

Feb 14, 2013

I have two tables one is

1)create table abc(c_name varchar2(10),c_number number(6),c_loc varchar2(8)); --having values
2)create table temp(sname varchar2(10),sid number(4),address varchar2(10));---no having

and my question is how to insert a values into temp using when-button-pressed trigger based on abc table in oracle form.

View 16 Replies View Related

Server Utilities :: Copy Table With NCLOB Column Into Another Database (10g To 11g)?

Dec 4, 2012

I need to copy one table which is having NCLOB column into our new DB(11g) from old DB (10g). As this table having huge records (1 crore) it is difficult to use direct insert statement (INSERT INTO ... SELECT * FROM @remotedb). I don't have DBA privilege to use loader.

View 3 Replies View Related

SQL & PL/SQL :: Copy Supplemental Login Information From Renamed Table To New Tables?

Oct 19, 2010

I renamed 100 tables and recreated them, now I need to copy supplemental login information from renamed table to new tables. Environment is oracle 10G.

OS - Solaris

View 9 Replies View Related

Server Utilities :: Copy Table With Special Char Between Oracle 8 And 10?

Nov 17, 2010

I have to copy a table from oracle 8 to oracle 10
- dblink don't work between 8 - 10
- can I dump table ?
- when I try to use sqlload via TXT file, I have error messages due to a column containing 'special' caracters (
,..) and line too long (splitted in several rows)

how can I do ?

View 1 Replies View Related

SQL & PL/SQL :: How To Rename A Index

Aug 8, 2011

How can i rename a index? is there a way except for drop and create.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved