0 votes
in Sql 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
+1 vote
asked Apr 6, 2022 in Python Packages and Data Access by sharadyadav1986
0 votes
asked Jun 12, 2020 in Python by Robindeniel
...