Drop a lot of tables with same prefix

Hello,
can you help me to do a script for drop all tables that have same prefix = TEST_LINK_?
thank you very much.
crystal

Hi crystal,
Here's some thing to start on. It does not handle any FK constraints on those tables, and assumes that the executor is owner.
declare
  pstmt  constant varchar2(255) := 'drop table :t purge';
  vstmt varchar2(255);
begin
for rec in (select table_name
              from user_tables
             where table_name like 'TEST_LINK\_%' escape '\')
   loop
      vstmt := replace(pstmt, ':t', rec.table_name);
      dbms_output.put_line(vstmt || ';');
--      execute immediate vstmt;
   end loop;
end;
/Regards
Peter

Similar Messages

  • How can i export the data to excel which has 2 tables with same number of columns & column names?

    Hi everyone, again landed up with a problem.
    After trying a lot to do it myself, finally decided to post here..
    I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
    It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
    Because both the tables have same number of columns & column names.
    Below are 2 tables with column names:
    Table-1 (MONTHLY_PART_1)
    Table-2 (MONTHLY_PART_2)
    SL_NO
    SL_NO
    COMP
    COMP
    DUE_DATE
    DUE_DATE
    U-1
    U-1
    U-2
    U-2
    U-4
    U-4
    U-20
    U-20
    U-25
    U-25
    Since both the tables have same column names, I'm getting the following error :
    Error 402 at line 103, column 4
      alias required in SELECT list of cursor to avoid duplicate column names.
    So How can i export the data to excel which has 2 tables with same number of columns & column names?
    Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
    Help me with this please.
    Thank You.

    You'll have to *alias* your columns, not prefix it with the table names:
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id, b.id, a.val1, b.val1, a.val2, b.val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
      for rData in cData loop
    ERROR at line 18:
    ORA-06550: line 18, column 3:
    PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
    ORA-06550: line 18, column 3:
    PL/SQL: Statement ignored
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
    PL/SQL procedure successfully completed.
    cheers

  • SQL 2008 how to compare & identify data among 2 tables with same structure ?

    Hello is there a TSQL way of comparing row by row for example comparing DateTimeStamp field in 2 separate tables with same structure in identifying if it's data was changed (If Table1.DateField > Table2.DateField THEN UPDATE it's entire row to match it's
    corresponding Table1 row.) ?
    Probably thinking would need a cursor to loop through or are there other better ways via TSQL ?
    Thanks in advance.

    Hi,
    I am assuming you have a PRIMARY KEY field or a UNIQUE field in both tables, which you should!
    You can do this using "UPDATE with INNER JOIN". (SQL Server – Update Table with INNER JOIN)
    Working example:
    USE [TestDatabase]
    GO
    /* Create Temp Tables */
    CREATE TABLE [dbo].[Table1]
    [ID] INT
    ,[Name] VARCHAR(10)
    ,[ModifyDate] DATETIME
    CREATE TABLE [dbo].[Table2]
    [ID] INT
    ,[Name] VARCHAR(10)
    ,[ModifyDate] DATETIME
    GO
    INSERT INTO [dbo].[Table1] ([ID], [Name], [ModifyDate]) VALUES (1, 'Vishal', GETDATE())
    INSERT INTO [dbo].[Table2] ([ID], [Name], [ModifyDate]) VALUES (1, 'Gajjar', GETDATE() + 1)
    GO
    SELECT [ID], [Name], [ModifyDate] FROM [dbo].[Table1]
    SELECT [ID], [Name], [ModifyDate] FROM [dbo].[Table2]
    GO
    UPDATE T1
    SET T1.[Name] = T2.[Name]
    FROM [dbo].[Table1] T1
    INNER JOIN [dbo].[Table2] T2 ON T1.[ID] = T2.[ID] /* Join on Key field */
    WHERE T2.[ModifyDate] > T1.[ModifyDate] /* Update criteria */
    GO
    /* CleanUp - Drop Tables
    DROP TABLE [dbo].[Table1], [dbo].[Table2]
    This Updates Table1 with latest values from Table2, You need to change the UPDATE statement for your scenario.
    - Vishal
    SqlAndMe.com

  • SSIS 2012 is intermittently failing with below "Invalid date format" while importing data from a source table into a Destination table with same exact schema.

    We migrated Packages from SSIS 2008 to 2012. The Package is working fine in all the environments except in one of our environment.
    SSIS 2012 is intermittently failing with below error while importing data from a source table into a Destination table with same exact schema.
    Error: 2014-01-28 15:52:05.19
       Code: 0x80004005
       Source: xxxxxxxx SSIS.Pipeline
       Description: Unspecified error
    End Error
    Error: 2014-01-28 15:52:05.19
       Code: 0xC0202009
       Source: Process xxxxxx Load TableName [48]
       Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Invalid date format".
    End Error
    Error: 2014-01-28 15:52:05.19
       Code: 0xC020901C
       Source: Process xxxxxxxx Load TableName [48]
       Description: There was an error with Load TableName.Inputs[OLE DB Destination Input].Columns[Updated] on Load TableName.Inputs[OLE DB Destination Input]. The column status returned was: "Conversion failed because the data value overflowed
    the specified type.".
    End Error
    But when we reorder the column in "Updated" in Destination table, the package is importing data successfully.
    This looks like bug to me, Any suggestion?

    Hi Mohideen,
    Based on my research, the issue might be related to one of the following factors:
    Memory pressure. Check there is a memory challenge when the issue occurs. In addition, if the package runs in 32-bit runtime on the specific server, use the 64-bit runtime instead.
    A known issue with SQL Native Client. As a workaround, use .NET data provider instead of SNAC.
    Hope this helps.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Get the Common from Two Internal Tables with same structure

    Hi ,
    I need to get the Common data from Two Internal Tables with same structure with using the looping method.
    For e.g.
    I have two internal table say ITAB1 and ITAB2.
    ITAB1 has values A,B,C,D,E,F
    ITAB2 has values A,H,B,Y,O
    Output at runtime should be : A,B

    Hi mohit,
    1. If u want to compare all fields,
       for matching purpose,
       then we can do like this.
    2.
    report abc.
    data : a like t001 occurs 0 with header line.
    data : b like t001 occurs 0 with header line.
    loop at a.
      LOOP AT B.
        IF A = B.
          WRITE :/ 'SAME'.
        ENDIF.
      endloop.
    ENDLOOP.
    regards,
    amit m.

  • 2 tables with same primary key

    Hi,
    2 tables with same primary key is possible,but when is wise to go for such ?
    is that a bad desisn ?
    eg:
    Personal_details_employee
    Official_details_employee
    these 2 tables have same Primary key emp_id.
    plz. reply me at [email protected] also
    thanx
    vikram

    hi Vikram,
    In this case u can have then in one table itself and why do want to have two tables.
    - Suresh.A

  • Funny bug in SQLDev 2.1EA - tables with same name...

    Hi,
    i opened two session in SQLDev 2.1EA, on two distinct instances.
    These sessions are open against the same user and i am clicking on a table with the same name.
    This happens only when the "pin" icon is not set.
    Apparently SQLDev doesn't not distinguish between the two connections when it comes to display the object attributes like columns, data, indexes and so on.
    So, practically, if i click on object 1 (instance 1), click on data tab, then i click on object 1 (instance 2), i still see the data for instance 1, no matter if i ask to refresh.
    This doesn't happen if i open each object in a separate tab.
    This happens on SQLDev on Mac OS X.
    Flavio
    http://oraclequirks.blogspot.com

    Sorry to drop in, but I suppose many have this setup: the same users/connections on both development and production databases.
    However I'm not able to reproduce now on my 10g DBs, I did see the same problem a couple of versions ago (when I was on 9i), but AFAIK that got fixed. Maybe regression anyway?
    Regards,
    K.

  • UPDATING A TABLE WITH SAME INFO FROM ANOTHER TABLE ON THE SAME DB

    0down votefavorite
    I am trying to update a table with info from another table on the same db with same table name. I just want the info to be the same , no primary key or constraint involve just a straight replacement of records and I keep getting errors WITH THE TABLE not
    being recignize. below is my query:
    UPDATE
    VNDFIL
    SET EOBTYP
    =  VNDFIL.EOBTYP, 
    EDI_X12_835_VERSION =  VNDFIL.EDI_X12_835_VERSION
    FROM
    AGERECOVERY
    WHERE
    VNDFIL.EOBTYP
    = VNDFIL.EOBTYP
    AND
    VNDFIL
    .EDI_X12_835_VERSION
    = VNDFIL.EDI_X12_835_VERSION

    Hi rotary,
    If those two same named tables are in the same database then they have to be in different schemas. If you mean they are in the same server instance, then they may be in different databases, besides the "table not being recognized" error,
    anyway you should use the fully qualified table names, that is database.Schema.Table(If across instances, ServerName should be prefixed) to avoid the table unrecognized error.
    Using Identifiers As Object Names
    With the fully qualified names, your update statement can be like below.
    UPDATE
    db1.schema1.VNDFIL
    SET EOBTYP = srcTbl.EOBTYP, EDI_X12_835_VERSION = srcTbl.EDI_X12_835_VERSION
    FROM
    db1.schema2.VNDFIL srcTbl
    WHERE
    db1.schema1.VNDFIL.EOBTYP = srcTbl.VNDFIL.EOBTYP AND
    db1.schema1.VNDFIL.EDI_X12_835_VERSION = srcTbl.VNDFIL.EDI_X12_835_VERSION
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Need to create a new row in table with same data as Primary key, but new PK

    Hello Gurus ,
    I have a table with one column as primary key, I need to create a new row in the table, but with same data as in one of the rows, but with different primary key, in short a duplicate row with diferent primary key ..
    Any ideas of how it can be done without much complication?
    Thanks in advance for your reply.
    Reards,
    Swapneel Kale

    user9970447 wrote:
    Hello Gurus ,
    I have a table with one column as primary key, I need to create a new row in the table, but with same data as in one of the rows, but with different primary key, in short a duplicate row with diferent primary key ..
    Any ideas of how it can be done without much complication?
    Thanks in advance for your reply.
    Reards,
    Swapneel Kalesomething like
    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')

  • Drop Down list in table with data from database table

    Hi,
    I have created an interactive form in WD ABAP.
    In Context tab I have created the nodes as follows:
    ZSOHEADER node with cardinality 1..1
    |-> MATERIAL node with cardinality 0..n. Under MATERIAL node there are 2 attrib. MAKTX and MATNR.
    I am fetching data from MARA table into an internal table IT_MARA.
    The node MATERIAL is bound to internal table IT_MARA.
    I have created a table with property ' Body rows vary depending on data ' .
    I have only one row in table. The first cell of the row is a drop down field.
    I have bind the field to the node MATERIAL->DATA->MAKTX.
    Now the issue is even though I have created only one row in my table, in preview it is creating as many rows in the table as the no.of records in the internal table.
    I want only one row with the drop down list containing all values of the internal table.
    Kindly suggest what to do.
    Regards,
    Vinod

    Hi,
    In the WebDynpro Context, in the main node create another node like A1 with cardinality 0..n and in this node create attributes TEXT and VALUE.
    Now goto method and in that method using code wizard read the node A1.
    And use the below code snippet sample in your program, i.e. code this under respective method of the webdynpro.
    *Declare the TYPES
    TYPES : BEGIN OF TY_TABLE,
    TEXT TYPE SOMETYPE,
    VALUE TYPE SOMETYPE,
    END OF TY_UOM.
    *Define Internal Table and work area.
    DATA : IT_TABLE TYPE STANDARD TABLE OF TY_TABLE INITIAL SIZE 0,
    WA_TABLE TYPE TY_TABLE.
    SELECT TEXT VALUE FROM TABLENAME INTO TABLE IT_TABLE.
    lr_node_info->bind_table( IT_TABLE ).
    And in the Adobe Form Layout
    Go to Menu of the Adobe LiveCycle Designer:
    Tools>Options..>DataBinding
    In that window you just check the Show Dynamic properties Check Box.
    Now for the Drop Down go the binding tab in object palette and click on the list items and there specify the Internal Table and specify the text as the internal table text field and value as internal table value field.
    OR
    From the WebDynpro Native Library Palette use the Value Help Drop Down and in object pallette goto binding tab and provide the form interface binding. Before this in the WebDynpro goto Context and for the particular field under the properties provide the search help as dictionary search help and specify the name of the dictionary search help.
    OR
    We have another method of setting the Text and Value to the DDL directly in the WebDynpro by coding in the methods, I dont have much knowledge on this.
    Regards
    Pradeep Goli

  • In OWB I need to update the target table with same field for match/update

    In OWb I am trying to update the target table with the match and the update on the same field can this be done. I am getting a error match merge error saying you cannot update and match on the same field. But in SQl my select is
    Update table
    set irf = 0
    where irf = 1
    and process_id = 'TEST'
    Hwo do i do this in OWB.

    table name is temp
    fields in the table
    field1 number
    field2 varchar2(10)
    field3 date
    values in the table are example
    0,'TEST',05/29/2009
    9,'TEST',05/29/2009
    0,'TEST1',03/01/2009
    1,'TEST1',03/01/2009
    In the above example I need to update the first row field1 to 1.
    Update temp
    set field1 = 1
    where field1 = 0
    and field2 = 'TEST'
    when I run this I just need one row to be updated and it should look like this below
    1,'TEST',05/29/2009
    9,'TEST',05/29/2009
    0,'TEST1',03/01/2009
    1,'TEST1',03/01/2009
    But when I run my mapping I am getting the rows like below the second row with 9 also is getting updated to 1.
    1,'TEST',05/29/2009
    1,'TEST',05/29/2009
    0,'TEST1',03/01/2009
    1,'TEST1',03/01/2009

  • Displaying several tables with same structure

    There are several tables with the same structure (number of columns, column names, column types etc.) and corresponding ADF BC view objects.
    A user should interactively choose the table he or she wants to edit. The UI remains the same for any given table.
    I need advice on how to implement this optimally, considering ease of development and performance.
    Right now I'm planning to use a SelectOneListbox for choosing and hide and show some containers with tables and forms for editing.
    I feel it should be quite easy, but I am an ADF newbie and feel puzzled :)
    Thanks in advance for any help!

    Hi,
    I feel your approuch will work fine . Check if following link can help
    http://www.oracle.com/technology/products/adf/patterns/11/enabledisablepattern.pdf
    Vikram

  • Query to insert a row in a table with same values except 1 field.

    Suppose I have a table with 100 columns(fields).
    I want to insert a row with 99 fileds being the same as previous ones except one fileld being different.
    The table doesn't have any constraints.
    Kindly suggest a query to solve the above purpose..

    And for much more lazy people, a desc of table is shorter to write. :-)
    Then copy & paste into any editor, then mode column to add a comma after every column name in one shot.Or have the system do it for you. Be lazy.
    SELECT Column_Name || ',' FROM User_Tab_Columns where Table_Name = '';
    Indeed, it can be converted to a script called desc(.sql)
    SELECT Column_Name || ',' FROM User_Tab_Columns where Table_Name = '&1' ORDER BY Column_Id;
    Then desc or @desc.

  • Regarding joining of two tables with same feilds

    hello gurus
    i am new to abap programming. i have to extract data from two tables ie coss and cosp tables . one table has 180 records and another table has 500 records i want to extract these two table records into internal table(680 records) and then i have to populate it to flatfile through gui download. can any one give me use code to work on it.these two tables has same set of feilds.

    Hi,
    First you should verify if you want to get all the data from both tables regardless if its the same record. If it is, then you can follow this logic:
    select * from coss into table it_coss_cosp. "step 1
    select * from cosp appending table it_coss_cosp. "step 2
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                  =
        filename                      = data.txt
      FILETYPE                      = 'ASC'
      APPEND                        = ' '
      WRITE_FIELD_SEPARATOR         = ' '
      HEADER                        = '00'
      TRUNC_TRAILING_BLANKS         = ' '
      WRITE_LF                      = 'X'
      COL_SELECT                    = ' '
      COL_SELECT_MASK               = ' '
      DAT_MODE                      = ' '
    IMPORTING
      FILELENGTH                    =
      tables
        data_tab                      = it_coss_cosp
    EXCEPTIONS
      FILE_WRITE_ERROR              = 1
      NO_BATCH                      = 2
      GUI_REFUSE_FILETRANSFER       = 3
      INVALID_TYPE                  = 4
      NO_AUTHORITY                  = 5
      UNKNOWN_ERROR                 = 6
      HEADER_NOT_ALLOWED            = 7
      SEPARATOR_NOT_ALLOWED         = 8
      FILESIZE_NOT_ALLOWED          = 9
      HEADER_TOO_LONG               = 10
      DP_ERROR_CREATE               = 11
      DP_ERROR_SEND                 = 12
      DP_ERROR_WRITE                = 13
      UNKNOWN_DP_ERROR              = 14
      ACCESS_DENIED                 = 15
      DP_OUT_OF_MEMORY              = 16
      DISK_FULL                     = 17
      DP_TIMEOUT                    = 18
      FILE_NOT_FOUND                = 19
      DATAPROVIDER_EXCEPTION        = 20
      CONTROL_FLUSH_ERROR           = 21
      OTHERS                        = 22
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    But if you plan to get those record which exists in both tables then use a join condition for your select statement.
    Hope this helps...
    P.S. Please award points for useful answers.

  • Concatenate tables with same name from different servers - CR2013

    Hello,
    I need some help.  I need data from 2 tables with the same name on different SQL servers thru an ODBC connection. When I try to get the data by adding both to my datasource I get data from one or the other.  I have considered creating a view, but not sure how to handle this.  Thanks.

    Hi,
    Linked Servers are pretty simple and straightforward, just do a search for the procedure.
    I do have an additional comment, though.  Depending on what tables you're gathering, I've found noticeable differences in performance when I use a connector to a DB on Server Instance "A" linked to "B" versus Server Instance B linked to A.  I haven't determined the circumstances affecting one over the other.
    If I'm not happy with speed using a connector A, I try switching to B.  I like to use as much SQL code as possible, but you can't get around the connector still being a factor.
    Matt

Maybe you are looking for

  • Unable to start SQL Server Browser service in Sql server 2005

    we are unable to start the SQL browser service on one of our machine with below error. I believe this to be the reason, why we could not connect to the instance with below error I tried troubleshooting as mentioned here, by changing value in registry

  • How to get the files related to a module from server

    Hi, I am facing a problem. i have to extends controller but it has lot of imports from the same module but different folders. and all the files are in .class files. Can you tell me a process where i can download onto my local system from the server a

  • Purchase Requisitions from Maintenance

    Dear Friends, We are implimenting Plant Maintenace and all other modules. Purchase requisitions are created with Maintenance Order automatically, and Purchase Requisitions will be created with MRP also. I want the Release strategy for MRP created PRs

  • Changing log file sizes

    is it possible to change je.properties : je.log.fileMax size and restart the db without having to dump and load it? i.e. is it okay to have different size log files in one environment?

  • Old Microsoft Word Doc Labels Stay up With Gestures after Closing Program

    Macbook Pro Early 2011 Just upgraded to Mavericks Don't even know if this is going to make sense... When I do the four-finger-up gesture the tags/labels (not the actual documents) of the documents I had up in Word yesterday are still up.  I've closed