I am using an Odbc connection with mysql server and wonder how I will check if a table exists in my database, and if not, create it.
Use CREATE TABLE IF NOT EXISTS.
CREATE TABLE IF NOT EXISTS
Not all RDBMSs are supported for recordingCREATE ... IF NOT EXISTS . MySQL does, but for those looking for a more portable solution, know that you have several (less efficient but functional) ways to achieve the same thing:
CREATE ... IF NOT EXISTS
CREATE TABLE
SELECT
tables
information_schema
@Derek
@lexu
information_schema.tables
create table if not exists NEW_TABLE_NAME , INFORMATION_SCHEMA. (, ).
create table if not exists NEW_TABLE_NAME
...
:
select count(TABLE_NAME) from INFORMATION_SCHEMA where TABLE_SCHEMA = 'your schema' and TABLE_NAME = 'your table' group by TABLE_NAME
Mysql "", , , , ., MySQL, !
mysql, , - , , . . , where, , . .
doco mysql . mysql, , , .