What happens if we try to create a table with an existing name?


#1

Question

In the context of this exercise, what happens if we try to create a table with an existing name?

Answer

When you try to create a table with an already existing table name, you will receive an error message, and no table will be modified or created.

Because SQLite (used in the exercises) is case insensitive for most syntax including names, this will apply to any casing of the table name. For instance, given the celebs table from this exercise, if you tried to run the following, it will throw an error, because the table name already exists.

CREATE TABLE Celebs (
   id INTEGER, 
   name TEXT, 
   age INTEGER
);