create a mysql database code example
Example 1: create database mysql
CREATE DATABASE `mydb`;
CREATE TABLE `my_table`
(
my_table_id INT AUTO_INCREMENT,
my_table_name VARCHAR(30) NOT NULL,
my_foreign_key INT NOT NULL,
my_tb_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
my_tb_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, ,
PRIMARY KEY(my_table_id),
CONSTRAINT fk_name_of_parent_table
FOREIGN KEY(my_foreign_key) REFERENCES parent_table(parent_table_column)
);
SHOW DATABASES;
Example 2: create databaste mysql
mysql> CREATE DATABASE databaseName;
Example 3: create database in mysql
The CREATE DATABASE statement is used to create a new SQL/MySQL database.
Syntax
CREATE DATABASE databasename;
CREATE DATABASE Example
The following SQL statement creates a database called "testDB":
Example
CREATE DATABASE testDB;
Example 4: create database terminal mysql
CREATE DATABASE dbname;
Example 5: mysql create database
CREATE DATABASE mydatabase CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Example 6: how to create database using cmd mysql
CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name]