MySQL Basic Query (DB Create, Delete, Table Create, Delete, Insert record, delete record)

Create Database

CREATE database example;

Delete Database

DROP database example;

Select Database

USE example;

View Database list

SHOW databases;

Create Table

CREATE TABLE test (
id int(11) not null auto_increment,
name varchar(10) not null,
email varchar(30),
primary key(id),
index name_index(name(10))  
)

View Table list

SHOW tables;

Delete Table

DROP table test;

Check Table Column Information

show columns from 'table name';
show full columns 'table name';

Insert Record

INSERT INTO test (name, email) VALUES("Lee", "seed@gmail.com");

Delete Record

DELETE FROM test WHERE id = 0;
DELETE FROM test     # Delete all data in the table

Modify Reocrd

UPDATE test SET email='example@gmail.com' WHERE name='Lee';

Select specific record

SELECT name,email FROM test WHERE name='Lee';

Leave a Reply