Help with SQL*Plus COPY Command syntax

Hello people.
DBs are 10g
PROD DB is a remote DB (over DB Link)
TEST DB is where my SQL*Plus is logged in.
LOCAL_DB_TABLE is the table I need to create to TEST DB
REMOTE_DB _TABLE is the table that already exists in remote PROD DB
COPY FROM replica/replica@PROD
CREATE LOCAL_DB_TABLE@TEST
ROW_ID,
CREATED,
CREATED_BY,
UPD,
UPD_BY
USING SELECT
ROW_ID,
CREATED,
CREATED_BY,
UPD,
UPD_BY
FROM REMOTE_DB_TABLE
WHERE ROW_ID='XXX';The error message I am getting:
usage: COPY FROM <db> TO <db> <opt> <table> { (<cols>) } USING <sel>
  <db>   : database string, e.g., hr/your_password@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
A missing FROM or TO clause uses the current SQL*Plus connection.
CREATE LOCAL_DB_TABLE@TEST
ERROR at line 1:
ORA-00901: invalid CREATE commandThank you in advance for your help.

Hi,
I hope you are thinking of Creating a Table with the Same Structure as the remote database Table, If so.
You can create a Table from the Existing Table using CTAS(Create Table as Select).
Provided, you have created a Database Links between the 2 Databases. You can create a
table in your Schema as,
CREATE TABLE local_db_table AS
SELECT * FROM remote_user_name.remote_db_table@dbname;Thanks,
Shankar
Edited by: Shankar Viji on Jul 19, 2012 11:01 PM

Similar Messages

  • ORA-01401 on execution SQL*Plus Copy command

    I looking solution for strange problem :
    I having two database created with AL32UTF8 character-set ; current application design are that we loading data throw SQL Loader and than transferring loaded data from one database to another using SQL*Plus copy command.
    Now , we having two tables , declared 100% identically , with respect to NLS and CHAR semantics (all varchar fields having CHAR inside length).
    At attempt to transfer data , with SQL*Plus Copy command I'm receiving next output :
    ERROR:
    ORA-01401: inserted value too large for column
    If I'm trying to transfer data via DB link , and this succeeds , or throw exp/imp utilities it also works .
    Database servers are 9.2 (i tryied with 9.2.0.6 or 9.2.0.8) ; client side were 9.2.0.8 , 10.1.0.5 ...
    On client side NLS_LANG variable are set to AMERICAN_AMERICA.AR8MSWIN1256 (we working on project who needs to support arabic language)
    Did anyone encountered same problem ? Any One ?

    it could be that the column of the table that you are trying to insert the data has a small length.

  • SQL*Plus 'Copy' command and LONG datatypes

    Hi. I'm using Oracle 9.2.0.5 and wanna copy LONG to LONG without using an Interface in VB or any other programming language.
    Some of the fields (plain text) are greater than 32 Kb, and I tried the SQL*Plus 'Copy' command, without success.
    (For compatibility reasons I can't convert LONG to CLOB, I need to copy LONG to LONG)
    This is the example I'm working with:
    Table Source_LONG (ID number, DATA long)
    Table Destination_LONG (ID number, DATA long)
    The SQL*Plus command: (connected from test_database@environment)
    set long 100000
    copy from test_database/test_database@environment insert destination_long (id,data)
    I tried using both FROM and TO, but same results.
    The fields are copied into destination_long, but they are
    truncated at 32768 bytes, even with the LONG variable set to 100000. Any ideas ?
    Thanks.

    I'm working with 2 similar tables with this structure:
    SOURCE_LONG (ID number, DATA long)
    DESTINATION_LONG (ID number, DATA long)
    SOURCE_LONG contains two rows:
    ID DATA
    1 hello
    3 ....text bigger than 32kb...
    I tried your solution and it insert 2 rows, but only the ID is filled. The DATA is empty in both cases :-(
    insert into destination_long(id,data) (select id,to_lob(data) from source_long);

  • SQL*Plus COPY command does not work

    SQL*Plus COPY command does not work in SQL Developer. I am using SQL Developer 1.5.1 on Windows XP.
    copy from <source_db_connection> to <target_db_connection> create <target_tab_name> using select * from <source_tab_name>
    Does it work on different versions of SQL Developer ?
    Anyone had any success in trying COPY command in SQL Developer?
    Thanks in advance.

    While it hasn't been updated for v1.5, this page lists the supported SQL*Plus commands. COPY is explicitly listed as not supported.
    theFurryOne

  • Help Using SQL*Plus Format Commands (like TTITLE) in Packages

    Where (within a package) can/should SQL*Plus format commands such as TTITLE, COLUMN & BREAK be coded?

    A package is coded in PL/SQL.
    TTITLE, COLUMN and BREAK are SQL*Plus commands, they cannot be used in PL/SQL.
    If you want to output data (using dbms_output) in your package, you'll have to implement the features yourself. But probably just using SQL*Plus is better in your case.
    Regards,
    Rob.

  • SQL PLUS Copy Command

    I'm having problems with the copy command in sql plus
    Here's my command
    COPY FROM tib_oms/tib_oms@odb1 -
    TO gbonk/gbonk@stage -
    INSERT -
    gbonk.products ( id_manufacturer, id_sku, category ) -
    USING -
    select id_mfr, sku, prodcat from tib_oms.pricinghistory
    The error I receive is...
    CPY0007: Select list has fewer columns than destination table
    I'm selecting 3 columns and I'm specifing 3 columns so I don't get what's up.
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Greg Bonk ([email protected]):
    Well i gave it a shot. Here's my modified copy command....
    copy from tib_oms/tib_oms@odb1 -
    TO gbonk/gbonk@stage -
    insert -
    gbonk.products ( "ID_MANUFACTURER", "ID_SKU", "CATEGORY" ) -
    using -
    select "ID_MFR", "SKU", "PRODCAT" from tib_oms.pricinghistory;
    But I still recieve the same error. Is there anything else that I could trouble shoot?<HR></BLOCKQUOTE>
    did u check if the destination & target columns have the same structure. maybe one of the is a composite datatype (i.e varray,nested tables etc) ?
    null

  • Need help with SQL*PLUS!

    I have just downloaded Oracle SQL*PLUS 9.2.0.1.0, but I am not able to use it because I do not know the "password", "user name" and "host string". Can anybody please help me with this.
    Thanks in advance,
    Flo

    The username & password are your database username & password. If you don't know these, you'll have to contact your DBA to find out.
    The host string is the alias you used when you configured TNS on your machine. Most commonly, this is done by editing the tnsnames.ora file or by using Net8 Easy Config.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • GPF in SQL*PLUS Copy Command?

    Hello,
    I'm getting a GPF and crash of SQL*Plus when I use the copy command. Seems like I used to be able to make it work if I tried logging on to the source database before the copy, but now even that won't work. I issue the command, it looks out over the modem for the remote database, then the GPF occurs.
    copy from me/[email protected] to me/me@LocalDB -
    insert ARRG_BNDRY_OBJECT -
    using -
    SELECT * FROM ARRG_BNDRY_OBJECT WHERE ARRG_BNDRY_KEY IN -
    (80169);
    Ideas?
    Thanks,
    Dale

    You might also want to try the same command using SQL*Plus command line (DOS version). If you haven't used it before, enter SQLPLUS at the command prompt, eg:
    c:\sqlplus
    Alison

  • SQL-Command to long to run with SQL*Plus

    Hello to everyone,
    I'm creating a dynamic SQL Script to run with SQL*Plus.
    The Script contains only INSERT Command.
    The point is that the SQL*Plus supports only SQL-Strings (Commands)
    not longer than 2500 Characters.
    I've considered to split the String in Insert- and Update-Command(s),
    but I've would like first to know if there any simpler way to run these
    Commands on SQL*Plus.
    thanx in Advance
    bm

    SQL> create table t(x varchar2(4000));
    Table created.
    SQL> insert into t values (
    '1234567890........0........0........0........0........0........0........0........0......100' ||
    '1234567890........0........0........0........0........0........0........0........0......200' ||
    '1234567890........0........0........0........0........0........0........0........0......300' ||
    '1234567890........0........0........0........0........0........0........0........0......400' ||
    '1234567890........0........0........0........0........0........0........0........0......500' ||
    '1234567890........0........0........0........0........0........0........0........0......600' ||
    '1234567890........0........0........0........0........0........0........0........0......700' ||
    '1234567890........0........0........0........0........0........0........0........0......800' ||
    '1234567890........0........0........0........0........0........0........0........0......900' ||
    '1234567890........0........0........0........0........0........0........0........0.....1000' ||
    '1234567890........0........0........0........0........0........0........0........0.....1100' ||
    '1234567890........0........0........0........0........0........0........0........0.....1200' ||
    '1234567890........0........0........0........0........0........0........0........0.....1300' ||
    '1234567890........0........0........0........0........0........0........0........0.....1400' ||
    '1234567890........0........0........0........0........0........0........0........0.....1500' ||
    '1234567890........0........0........0........0........0........0........0........0.....1600' ||
    '1234567890........0........0........0........0........0........0........0........0.....1700' ||
    '1234567890........0........0........0........0........0........0........0........0.....1800' ||
    '1234567890........0........0........0........0........0........0........0........0.....1900' ||
    '1234567890........0........0........0........0........0........0........0........0.....2000' ||
    '1234567890........0........0........0........0........0........0........0........0.....2100' ||
    '1234567890........0........0........0........0........0........0........0........0.....2200' ||
    '1234567890........0........0........0........0........0........0........0........0.....2300' ||
    '1234567890........0........0........0........0........0........0........0........0.....2400' ||
    '1234567890........0........0........0........0........0........0........0........0.....2500' ||
    '1234567890........0........0........0........0........0........0........0........0.....2600' ||
    '1234567890........0........0........0........0........0........0........0........0.....2700' ||
    '1234567890........0........0........0........0........0........0........0........0.....2800' ||
    '1234567890........0........0........0........0........0........0........0........0.....2900' ||
    '1234567890........0........0........0........0........0........0........0........0.....3000'
    1 row created.try to break your query in multiple lines in order to avoid
    SP2-0027: Input is too long (> 2499 characters) - line ignored

  • W'azup with SQL Developer barfing on SQL*Plus "set" commands

    Check out this short script and the results it generates, as pasted below.
    I can't find anything in the SQL Dev documenation re: what SQL*Plus set commands it supports and which it considers "passe." I'm particularly puzzled by the "column ... format ..." command getting ignored.
    set heading off
    set pagesize 0
    set linesize 80
    set feedback off
    prompt ...start...
    column x format a5
    select 'abcdefghij' x from dual;
    prompt ...end...
    line 1: SQLPLUS Command Skipped: set heading off
    line 2: SQLPLUS Command Skipped: set pagesize 0
    line 3: SQLPLUS Command Skipped: set linesize 80
    ...start...
    X ----------
    abcdefghij 1 rows selected
    ...end...

    For supported SQL*Plus commands: SQL Developer Help > SQL Developer Concepts and Usage > Using the SQL Worksheet > SQL*Plus Statements Supported and Not Supported in SQL Worksheet.
    The "column ... format ...." command is not supported. A workaround is to use substr in your select statement.
    See also How to set a column size in sqldeveloper?

  • Learning PL/SQL with SQL plus

    I'm looking to teach myself PL/SQL with SQL Plus, it's a works pc so I can not use any other software than SQL plus.
    When starting SQL plus I'm asked for a username, password and host string.
    I'm taking it the host string is the db I want to connect to and obviously supply the username and password for level of access?
    Also what I ideally need is a sample db on my local machine to connect to with SQL plus to learn that way.
    Can anyone point me in the right direction please. Any help is greatly appreciated.

    Use the net8 configuration assistant preferably as it'll get the syntax correct.
    Otherwise you copy the sample one up one folder and edit that.
    Connection information (SID, Server/IP, port number) you'll have to get off your DBA.
    The name at the start of a tnsnames entry is the name that you want to reference the database as, so you can call it FRED if you like.
    e.g.
    FRED =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS =
            (PROTOCOL = TCP)
            (HOST = <server name or ip address>)
            (PORT = <port>) -- usually 1521 but can differ if more than one instance on the server
        (CONNECT_DATA =
          (SID = <database SID>) -- the name of the database on the server.
      )Once that's set up you can then log onto the database in the following way:
    sqlplus <user>/<password>@fred
    What happens is that the TNS Listener service (that should be running on your PC) will look up "fred" in the tnsnames.ora file and then use the information from that to make the connection to the server on the correct port and connect you to the actual database on there.
    After that.... it's up to you.
    :)

  • How to Hide password when invoking sql plus from command promt?

    When i try to open sql plus in command prompt window and enter the sqlplus command follwed by username/password@connection string, the password is not hidden.
    How do I get it to show **** instead of displaying password characters out?
    Also, what is the command to clear screen : when I try cls or clear screen, I get a windows memory exception of somekind and the only option there is to kill the command window.
    Any tips on getting around this?
    Thanks a lot for your time and help.

    user8848256 wrote:
    Can you please give more details on how to not enter password when calling sqlplus from command window like you are saying?
    I tried this :
    sqlplus username/ @connection string -->Hit Enter : it asks for password but does not recognise the connectionstring to connect to.
    sqlplus username/ -->Hit Enter: It does same thing again.asks for password but gives tns adapter error after the password is entered.Leave out the slash:
    sqlplus username@connect_string

  • Downloading and installing Oracle (with sql plus) on Windows 7 Professional

    Hi,
    I got a new laptop which has Windows 7 Professional (64 bit). I intend to download Oracle 10g and would like to install bothe the database and the sql plus in this system.
    I would appreciate if somebody could provide me a link to the appropriate database (with sql plus installation capability). Also if available the installation guide.
    Thanks in advance.

    Hello,
    Windows 7 Professional (64 bit). I intend to download Oracle 10g and would like to install bothe the database and the sql plusOracle *10g* is not certified on Windows *7*, except with the latest patchset *10.2.0.5*, and its Premium Support ended on the *31st of July 2010*.
    You should download Oracle *11.2* which is certified on Windows *7 - 64 bit*.
    You'll find the Documentation and Download tabs on the link below:
    http://www.oracle.com/technetwork/database/enterprise-edition/overview/index.html
    About SQLPlus, it's delivered with Oracle Server and, in *11g*, you can still use it from a DOS box. If you intend to have a Graphical Tool, you should use Oracle SQL Developer instead:
    http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html
    Hope this help.
    Best regards,
    Jean-Valentin

  • Preference equivalents for relevant SQL*Plus set commands?

    I know that the SQL*Plus set command is not supported in Raptor (as per http://www.oracle.com/technology/products/database/project_raptor/sql_worksheet_commands.html), but there are a number of set options that are relevant.
    For example, set define (for which "set define off" is covered in Ampersand in scripts We have a number of existing SQL scripts where we have set the define character to something apart from & to avoid issues where this is a required value in the code.
    Setting server output size is another option - as per set serveroutput on size unlimited .
    Is there any proactive plan to provide preferences equivalent to the set options that are relevant (to either SQL scripts or the various output tabs)? Or is the exclusion of the SQL*Plus set command only for the current version and it will be included later? From the discussion on the forums so far, it seems as though you are looking at each set option as it is raised, rather than being proactive about it.
    Even if Raptor does provide preferences, it would still be useful for the equivalent set commands to work. Lets say that we do get a preference for the define character - 99% of the time, scripts want this to be & - however there are some where the script wants it to be $ (or whatever). With a preference, I need to know what the script wants and change the preference before running the script and then change it back afterwards.

    Hi Turloch,
    When is this script executed ?
    In 3.1EA2 I created a sql script where a variable is defined and set this script as you suggested.
    Script:
    define varname=abc
    When I open a connection, a worksheet is automatically opened. I run this statements:
    select '&varname' from dual;
    define varname=xyz
    select '&varname' from dual;
    Running the first select statement results in a popup window for entering a value for the substitution variable, while I was expecting the value abc as the result of the query.
    See also this blog where the login script is explained.
    But in my SQL Developer 3.1EA2 64-bit on Windows 7 it doesn't work like that.
    Is this a bug?
    Dennis

  • Backspace with SQL*Plus

    Hi,
    when I use backspace on my keyboard with SQL*Plus or svrmrgl,
    the symbol ^h is comming on my screen.
    But I want delete the character before the cursor.
    Any idea ???
    Thanks
    null

    Pardon my ignorance, but what's the significance of the N'<string>' construction? That's not one I'm familar with.
    Justin

Maybe you are looking for