CrazyEngineers
  • how to create new table from existing table in sql server

    bohar

    bohar

    @bohar-wQr9Oe
    Updated: Oct 21, 2024
    Views: 1.0K
    I want to use only one query - the problem is: how to create new table from existing table in sql server
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Leo

    MemberNov 12, 2010

    create table newtable_name like database_name.old_table_name;

    insert into newtable_name selcet * from database_name.old_table_name;

    This will copy your previous table to new table. Happy computing.
    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberNov 12, 2010

    create table new-table-name (column-list) as select (column-list) from existing-table-name;

    What's this then?
    Are you sure? This action cannot be undone.
    Cancel
  • Saandeep Sreerambatla

    MemberNov 12, 2010

    In Oracle,

    Create table temp as select * from old table. -- will this not do?
    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberNov 12, 2010

    English-Scared
    In Oracle,

    Create table temp as select * from old table. -- will this not do?
    This is same as the query I have given.

    create table new-table-name (column-list) as select (column-list) from existing-table-name;

    In your query, temp is the new-table-name and old table refers to the existing-table-name. I had specified the column-list to select particular columns and you used * to select all the columns, Isn't it?

    This will definitely works.
    Are you sure? This action cannot be undone.
    Cancel
  • bohar

    MemberNov 13, 2010

    select * into table_new from table_old
    this query work in sqlserver,but i have no idea that about, this will work in oracle,mysql or not
    Are you sure? This action cannot be undone.
    Cancel
  • 4M4N

    MemberNov 13, 2010

    Suppose u have table employee having cols eno, ename, salary and adress, now for making exact copy of that table of name emp2 the following query can be used

    create table emp2(eno int, ename varchar(50), salary int, address varchar(50)) select eno , ename , salary , address from employee;
    (tested)
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register