CREATE TABLE
statement creates a new table in a database. Each table has columns with specific data types like numbers, strings, or dates.
table_name
: Name of the tablecolumn_1, column_2, column_n
: Names of the columnsdatatype
: Data type for each columnIF NOT EXISTS
(Optional): Use this to avoid errors if the table already existspublic
schema, but you can specify a different schema. For more information, click here.IF NOT EXISTS
clause. See the following examples:
IF NOT EXISTS
option:IF NOT EXISTS
, you will get the following error:
IF NOT EXISTS
option to avoid the error:
IF NOT EXISTS
allows the query to succeed even if the table already exists.