in Technology by
How to create empty tables with the same structure as another table?

1 Answer

0 votes
by

Creating empty tables with the same structure can be done smartly by fetching the records of one table into a new table using the INTO operator while fixing a WHERE clause to be false for all records. Hence, SQL prepares the new table with a duplicate structure to accept the fetched records but since no records get fetched due to the WHERE clause in action, nothing is inserted into the new table.

SELECT * INTO Students_copy
FROM Students WHERE 1 = 2;

    Related questions

    0 votes
        I have three same source structure tables. But, I want to load into single target table. How do I do this? Explain in detail through mapping flow....
    asked Mar 28, 2021 by JackTerrance
    0 votes
        I have two different source structure tables, but I want to load into single target table? How do I go about it? Explain in detail through mapping flow....
    asked Mar 28, 2021 by JackTerrance
    0 votes
        Hi I have two tables here: Transcript Grade Student_number Course_number Semester Year A 8 MATH2410 Fall 07 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
    asked Apr 2, 2022 in Education by JackTerrance
    0 votes
        Hi I have two tables here: Transcript Grade Student_number Course_number Semester Year A 8 MATH2410 Fall 07 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
    asked Apr 2, 2022 in Education by JackTerrance
    0 votes
        Before starting to enter data in a table, you must create the: a. Design of the table c. Database from which to ... d. All of these Select the correct answer from above options...
    asked Dec 31, 2021 in Education by JackTerrance
    0 votes
        I am getting empty row on following sql SELECT * FROM flyers WHERE fId='6' AND 'userId'='400' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
    asked Jun 8, 2022 in Education by JackTerrance
    0 votes
        SQL structure such as table names, column names, and so on cannot be escaped, and thus user-supplied structure names are ... issue in a report-writing software. 1. True 2. False...
    asked Mar 20, 2021 in Technology by JackTerrance
    0 votes
        I'm trying to reproduce this SQL statement using NH DetachedCriteria but struggling to get all 3 inner join ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
    asked Feb 20, 2022 in Education by JackTerrance
    0 votes
    0 votes
        A lock that prevents the use of any tables in the database from one transaction while another ... Multiversion Schemes in section Concurrency Control of Database Management...
    asked Oct 10, 2021 in Education by JackTerrance
    0 votes
        A lock that allows concurrent transactions to access different rows of the same table is known as a ( ... Protocols topic in section Concurrency Control of Database Management...
    asked Oct 10, 2021 in Education by JackTerrance
    0 votes
        How to set same number 'priority' with one query for Mercedes. +--------------------- ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
    asked Jul 20, 2022 in Education by JackTerrance
    ...