Set up a database
CREATE DATABASE ff default character set UTF8;
Create database if not EXISTS FF default charcter set UTF8;
Deleting a database
drop database ff;
Drop database if exists ff;
Querying the database
Show CREATE DATABASE db;//query Build database statement
Show CREATE DATABASE mysql;//query Build database statement
Modifying the database Character set
ALTER DATABASE ' BD ' character set UTF8;
Displays the current database name
Select Database ();
Querying MySQL data for current version information
Select version ();
The difference between InnoDB and MyISAM is
InnoDB adds things to the SQL default database storage engine
Mysam does not have this feature
Table Operations
field data type, use a database before you can create a table
Use AA;
Create a table
Simple CREATE table t3 (t int);
Create Tables Stu (
Sno int unsigned auto_increment,//For integer self-increment
sname varchar () not NULL,//name up to 15 characters and cannot be empty
Sscore tinyint unsigned,//unsingned means unsigned, as long as the integral type must have, cannot be negative
Primary KEY (SNO)//Primary key setting allows SNO serial number to be not duplicated
) Engine=myisam auto_increment=201501 default CharSet UTF8;
Comment ' Student name ' indicates a comment
CREATE TABLE ABB (
SS INT UNSIGNED Auto_increment,
Sname VARCHAR (+) not NULL COMMENT ' student name ',
Sage TINYINT UNSIGNED COMMENT ' student age ',
PRIMARY KEY (ss)
) Engine=myisam auto_increment=20151 DEFAULT CHARSET UTF8;
Insert the table, the number is customized to 4 digits, if not enough four bits automatically fill up 0 Zerofill to indicate auto-fill 0
CREATE TABLE B (
SS INT (4) UNSIGNED Zerofill not NULL auto_increment COMMENT ' student number ',
Sname VARCHAR (+) not NULL COMMENT ' student name ',
Sage TINYINT UNSIGNED COMMENT ' student age ',
PRIMARY KEY (ss)
) Engine=myisam auto_increment=1 DEFAULT CHARSET UTF8;
CREATE TABLE St (
Sno INT UNSIGNED Auto_increment,
Sname VARCHAR () not NULL,
Ssocre TINYINT UNSIGNED,
PRIMARY KEY (SNO)
) Engine=myisam auto_increment=2 DEFAULT CHARSET UTF8;
Displays all table information for the current database
Show tables;
Find the contents of the St table
SELECT *from St;
Delete a table
drop table AA;
drop table aa,a1;
Modify Table Name
Rename table T1 to T2;
Cross-Library query in the AA database Environment Stu table in DB database
Use AA;
Select*from Db.stu;
To modify the table's engine:
Use AA;
ALTER TABLE book ENYINE=INNODB;
View the structure of a table
DESC AA; ==describe;
Inserting data
INSERT ABB VALUE (NULL, ' John Doe ', 90);
The file that controls the default engine is
My.ini is the MY.CNF under the Windows system is the Linux system
My.ini Windows System
[Client]
port=3306
Default-character-set=utf8
[MySQL]
Default-character-set=utf8
[Mysqld]
port=3306
Character-set-server=utf8
Default-storage-engine=myisam
Adding this code allows the default character set to be utf8;
Select User (); Current user
Select Curtime (); Current time
Select Curdate (); The current date
--Database Comment statement single line comment/* Multiline comment */
Mysqld--install Installation
net start MySQL Open service
net stop MySQL stop service
Mysqld--remove Removing a server
Mysql-uroot login MySQL
E:\MYSQL\BIN>MYSQL-UROOT-P login MySQL
Enter password: Empty direct hit Enter
E:\mysql\bin>mysql-h localhost-u root-p Login MySQL
Enter Password:
MYQL Basic Library Table operations