0 votes
in MariaDB by
How to create a table in MariaDB's database?

1 Answer

0 votes
by
First, you have to create a database in MariaDB follows by selecting the database and then create a table by using the CREATE TABLE statement. You must have the CREATE privilege for a table or on the database to create a table.

Create table statement creates a table name followed by a list of columns, indexes, and constraints. By default, a table is created in the default database

Syntax:

CREATE TABLE table_name (column_name column_type);     

For example

1.  CREATE TABLE Students(    

2.  student_id INT NOT NULL AUTO_INCREMENT,    

3.  student_name VARCHAR(100) NOT NULL,    

4.  student_address VARCHAR(40) NOT NULL,    

5.  admission_date DATE,    

6.  PRIMARY KEY ( student_id ));  

Output:

Query OK, 0 rows affected (0.312 sec)

You can verify that whether the table is created by using SHOW TABLES command.

SHOW TABLES;
...