Sponsored Links
Sponsored Link

sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Is there a way to create a table as same as another by ignoring one field?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there a way to create a table as same as another by ignoring one field?

    Using STRSQL, Is there a way to create a Table2 as same as another Table1 by ignoring one field out of 100 fields from Table1?


  • #2
    I'm not sure what you're asking.

    You can:

    Code:
    CREATE TABLE TABLE2 AS (SELECT FIELD1,FIELD2,....FIELD98,FIELD100 FROM TALBE1) WITH NO DATA
    Are you asking if there's a way to:

    Code:
    CREATE TABLE2 AS (SELECT * FROM TABLE1) WITH NO DATA
    But have the ability to exclude a cell/field?

    Well - yes....

    Code:
    CREATE TABLE TABLE2 AS (SELECT * FROM TABLE1) WITH NO DATA
    Then execute an ALTER TABLE command:

    Code:
    ALTER TABLE TABLE2 DROP COLUMN field98 CASCADE
    This creates a table TABLE2, then removes the field specified in the ALTER TABLE from that definition.

    Does this help?

    Comment


    • #3
      Rocky's drop column method is the quickest way, but if you'd rather not do that, then to make things a bit easier to generate the column list when using STRSQL, you can:

      enter query:
      <code>
      select * from TABLE1
      </code>

      Then press F4 to prompt the command. This provides a CL command like interface for specifying the components of the statement
      Delete the asterisk in the "SELECT fields" option, then press F4 to prompt that. This presents a list of every field in the file
      Type a '1' next to every field except the one you want to keep. Most terminal emulators let you block select/copy/paste, so you could populate the '1s on the first page of fields, copy them, then paste them on every other page
      Press enter to confirm the list of fields, then enter again to complete and run the query, then enter again to return to the main STRSQL screen, then F9 to pre-populate with the previous statement (the 99 field select):

      <code>
      select field1,field2, ... field100 from TABLE1
      </code>

      Then you can wrap it with the create table statement as in Rocky's first example

      Comment


      • Vectorspace
        Vectorspace commented
        Editing a comment
        I used the wrong code tags and I can't edit my posts so I can't correct it - but hopefully it still makes sense

    sponsored links

    Collapse

    Working...
    X