MySQL: The most widely adopted open source database management system
Tue Jun 2 2:57 pm EDT 2026xtmci@atomicmail.io
Table of Contents
- SELECT ... FROM statement
- INSERT INTO statement
- DELETE FROM ... WHERE statement
- UPDATE ... SET ... WHERE statement
- CREATE TABLE statement
- SHOW statements
- Utility statements
SELECT ... FROM statement
The select ... from statement selects data from a database. The returned data set is stored in a table. The syntax of the statement is as follows:
SELECT column1, column2, ... FROM table;
When selecting all columns in a record, use * instead of column names:
SELECT * FROM table;
INSERT INTO statement
The insert into statement inserts a new record into a table. The syntax of the statement is as follows:
INSERT INTO table (column1, column2, ...) VALUES (value1, value2, ...);
DELETE FROM ... WHERE statement
The delete from ... where statement deletes records from a table. Here is the syntax of the statement:
DELETE FROM table WHERE condition;
Make sure you specify a condition or set of conditions in the where clause. If you omit it, all records in the table will be deleted permanently.
UPDATE ... SET ... WHERE statement
The update ... set ... where statement updates the records specified by where clause. Here is the syntax of it:
UPDATE table SET column1=value1, column2=value2, ... WHERE criteria;
Make sure not to omit the where clause. Otherwise, all rows in the table will be modified.
CREATE TABLE statement
The create table statement creates a new table in a database. The syntax of it is as follows:
CREATE TABLE table ( column1 data_type1 column_rules1, column2 data_type2 column_rules2, ... );
An optional parameter column_rules (also called constraint) specifies a set of rules applied to a column. Here is an example:
CREATE TABLE members ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, address VARCHAR(200), birthday DATE );
SHOW statements
SHOW COLUMNS FROM statement
The show columns from statement displays information about the columns in a table.
SHOW COLUMNS FROM table;
SHOW TABLES statement
Use the show tables statement to list the tables in a database. Make sure first select a database using use statement.
SHOW TABLES;
Utility statements
DESCRIBE and EXPLAIN statements
The DESCRIBE and EXPLAIN are synonyms. They are used to provide structural information about a table.
DESCRIBE table;
EXPLAIN table;
USE statement
The use statement selects a database to be used as the current database. The selected database remains as a default until another use statement is issued.
USE database;