Installation process: [MySQL] Win8 installation process and problems encountered.
Course: Learn MySQL database in one day.
Instruction quick check: MySQL tutorial
MySQL commands are not case sensitive~
Login and logout
The account name is root and the password is 100
mysql -uroot -p110
exit;
Create, delete, display, select database
create
create DATABASE test;
delete
drop database test;
display
show databases;
select
use test
View, create, delete data tables
PS First enter the specified database to
view all tables
show tables;
View specific information of a form
desc tablename
Basic creation
CREATE TABLE student(id INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id))
Advanced creation
CREATE TABLE IF NOT EXISTS student(id INT NOT NULL AUTO_INCREMENT,
gender VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
date DATE,
PRIMARY KEY(id))ENGINE=InnoDB DEFAULT CHARSET=utf8;
delete
DROP TABLE student;
Add, delete, check and modify data
Increase (id will automatically increase, so no need to set)
INSERT INTO student(gender, name, date) VALUES('boy','Tom',NOW());
check
SELECT column_name,column_name
FROM table_name
[WHERE Clause]
[LIMIT N][ OFFSET M]
- You can use one or more tables, use a comma (,) to separate the tables, and use the WHERE statement to set the query conditions
- You can use an asterisk (*) to replace other fields, the SELECT statement will return all the field data of the table
- You can use the WHERE statement to include any conditions
- You can use the LIMIT attribute to set the number of records returned
- You can use OFFSET to specify the data offset at which the SELECT statement starts to query. The offset is 0 by default
delete
DELETE FROM student WHERE id=1;
change
UPDATE table_name SET field1=new-value1, field2=new-value2
[WHERE Clause]
例如:
update student set gender='gril', name='GiGi' where id=2;
Special query conditions
WHERE to conditionally select data
SELECT field1, field2,...fieldN FROM table_name1, table_name2...
[WHERE condition1 [AND [OR]] condition2.....
- To specify one or more conditions using AND or OR
- The WHERE clause can also be used in SQL DELETE or UPDATE commands
LIKE
- Use the percent sign% character to represent any character, similar to the asterisk * in UNIX or regular expressions.
- If the percent sign% is not used, the LIKE clause has the same effect as the equal sign =
'%a' //Data ending with
a'a%' //Data starting with a
'%a%' //Data containing a
' a ' //Three digits and the middle letter is a
' a'/ /
'A ' with two digits and the end letter is a //Two digits and the beginning letter is a
The database is composed of a sheet of tables. The
primary key is the unique identifier that distinguishes the data. The
basic type of the database is
accurate to the day
timestamp and accurate to the second