Jun-28-2022, 07:50 AM
I never understood why there is a need for IF NOT EXISTS.
Create a table you need for a purpose. Check first if a table with that name exists.
Once you create a table in your db, unless you will only import data with fixed ids (I do that often), you need to set the initial value for the primary key:
for example.
The first INSERT query will then take the id value 1. Further INSERT queries will increment id from 1.
Why would you run the same CREATE TABLE again? Not a realistic scenario.
Create a table you need for a purpose. Check first if a table with that name exists.
Once you create a table in your db, unless you will only import data with fixed ids (I do that often), you need to set the initial value for the primary key:
Quote:ALTER TABLE my_table AUTO_INCREMENT = 1;
for example.
The first INSERT query will then take the id value 1. Further INSERT queries will increment id from 1.
Why would you run the same CREATE TABLE again? Not a realistic scenario.