Why use "where 1=2" on a SQL CREATE TABLE syntax?

Solution 1:

This type of command is usually used to copy the structure of one table to another. In this case, EMPL_DEMO will have the same column structure of employees, except for the keys or constraints.

The 1=2 always evaluates to False which prevents you from copying any of the rows.

Solution 2:

CREATE TABLE (Create A New Table)

EMPL_DEMO (Called EMPL_DEMO)

AS (With The Data and structure of)

SELECT * FROM employees WHERE 1=2; (Everything in employees where 1=2. Since 1 is never 2 - copy the structure and all 0 matching rows)

..Essentially copy structure and not data.

Solution 3:

This syntax does the same, but it's more obvious, it creates a table with the same structure, with no data.

CREATE TABLE EMPL_DEMO AS SELECT * FROM employees limit 0;