Kaigai Blog living abroad in my twenties

【My Study Note】Creating a Database With MySQL

MySQL Programming

Creating a Database With MySQL

1. Starting up mySQL and login

mysql --user=root --password

2. Creating a Database

SHOW databases;
CREATE DATABASE newTable;

3. Creating a Table

USE newTable;
SHOW tables;
CREATE TABLE users (
`id` int auto_increment, 
`name` text, 
primary key (id)
);

Primary Key

A primary key is a constraint placed on a database table column to uniquely identify a record, and duplicated values cannot be placed in the set column.

// Check the created table structure
DESCRIBE users;

4. Deleting the Created Database and Table

SHOW tables;
DROP TABLE users;
SHOW databases;
DROP DATABASE newTable;