example create database
Example 1: create database sql
CREATE TABLE example (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
Example 2: MySQL CREATE DATABASE
MySQL implements a database as a directory that contains all files which correspond to tables in the database.
To create a new database in MySQL, you use the CREATE DATABASE statement with the following syntax:
CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name]
Example 3: CREATE DATABASE DatabaseName;
SHOW DATABASES;
DROP DATABASE testDB;
USE DatabaseName;
SQL> CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
DESC CUSTOMERS;