Search code examples
sqloracle-databaseddlcreate-table

What is the meaning of 1=2 when copying database structure?


I've come across

create table new_table as select * from old_table where 1=2;

What is the meaning of the where 1=2 condition and what function does it perform?


Solution

  • 1=2 always evaluates as false. This is a common trick to utilize the create as select to copy a table's structure without copying any of its rows (as none of them will pass the test of 1=2).