How to create MySQL MSSQL and PostgreSQL database
Posted: Fri Mar 03, 2017 2:30 pm
I want to create a database and it's tables&fields automatically from livecode script.
As basis information I have the SQLite (development version) database available that shows the information below in SQLiteExpert in the DDL tab http://www.sqlite.org/.
Theoretical this information should be sufficient to enable me to generate a database including its tables and fields.
On the MySQL site (see links below) it states that I am able to create a database with 'CREATE DATABASE Databasename;'
And I also should be able to do the same with 'CREATE TABLE tablename;' and it's fields.
My question is: How can I do this from within livecode script for non SQLite databases and specifically MySQL MSSQL and PostgreSQL databases?
--- Information from SQLiteExpert in the DDL tab. ------------------------
CREATE TABLE [Table_1](
[Field_A] TEXT(6) NOT NULL ON CONFLICT FAIL,
[Field_B] TEXT NOT NULL ON CONFLICT FAIL,
[Field_C] TEXT NOT NULL ON CONFLICT FAIL,
[Field_D] TEXT NOT NULL ON CONFLICT FAIL,
[Field_E] TEXT,
[Field_F] TEXT NOT NULL ON CONFLICT FAIL,
UNIQUE([Field_A] ASC, [Field_B] ASC, [Field_C] ASC) ON CONFLICT FAIL);
CREATE TABLE [Table_2](
[Field_A] TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT FAIL,
[Field_B] TEXT,
[Field_C] TEXT,
[Field_D] TEXT,
[Field_E] TEXT);
---------------------------
Links:
https://dev.mysql.com/doc/refman/5.7/en ... abase.html
https://dev.mysql.com/doc/refman/5.5/en ... table.html
Kind regards,
Paul
As basis information I have the SQLite (development version) database available that shows the information below in SQLiteExpert in the DDL tab http://www.sqlite.org/.
Theoretical this information should be sufficient to enable me to generate a database including its tables and fields.
On the MySQL site (see links below) it states that I am able to create a database with 'CREATE DATABASE Databasename;'
And I also should be able to do the same with 'CREATE TABLE tablename;' and it's fields.
My question is: How can I do this from within livecode script for non SQLite databases and specifically MySQL MSSQL and PostgreSQL databases?
--- Information from SQLiteExpert in the DDL tab. ------------------------
CREATE TABLE [Table_1](
[Field_A] TEXT(6) NOT NULL ON CONFLICT FAIL,
[Field_B] TEXT NOT NULL ON CONFLICT FAIL,
[Field_C] TEXT NOT NULL ON CONFLICT FAIL,
[Field_D] TEXT NOT NULL ON CONFLICT FAIL,
[Field_E] TEXT,
[Field_F] TEXT NOT NULL ON CONFLICT FAIL,
UNIQUE([Field_A] ASC, [Field_B] ASC, [Field_C] ASC) ON CONFLICT FAIL);
CREATE TABLE [Table_2](
[Field_A] TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT FAIL,
[Field_B] TEXT,
[Field_C] TEXT,
[Field_D] TEXT,
[Field_E] TEXT);
---------------------------
Links:
https://dev.mysql.com/doc/refman/5.7/en ... abase.html
https://dev.mysql.com/doc/refman/5.5/en ... table.html
Kind regards,
Paul