MariaDB Data Definition for Creating Table
MariaDB Data Definition for setting up a table’s schema.
Table Example
1 | CREATE TABLE customer( |
Test Data
1 | INSERT INTO customer (first_name, last_name, email, active_days, city, verified, created_at) VALUES('Alice', 'Ali', 'alice@example.com', 55, 'Boston', 1, "2012-04-19 13:08:22"); |
Data Types
MariaDB supports Numeric, String and Date Times.
All DataTypes can be found from this documentation MariaDB Data Types
Column Definition
NOT NULL
Use the NULL or NOT NULL options to specify that values in the column may or may not be NULL, respectively.
AUTO_INCREMENT
Use AUTO_INCREMENT to create a column whose value can can be set automatically from a simple counter.
UNIQUE KEY
Use UNIQUE KEY (or just UNIQUE) to specify that all values in the column must be distinct from each other.
PRIMARY KEY
Use PRIMARY KEY (or just KEY) to make a column a primary key.
FOREIGN KEY
A foreign key is a constraint which can be used to enforce data integrity. It is composed by a column (or a set of columns) in a table called the child table, which references to a column (or a set of columns) in a table called the parent table.
Syntax:
1 | [CONSTRAINT [symbol]] FOREIGN KEY |