--View the SQL statement that created the database
Show CREATE Database mydb;
--View the character sets supported by the currently installed MySQL.
Show CharSet;
--View MySQL database server and database character set
Show variables like '%char% ';
--View the SQL statement that created the table
Show create TABLE classes;
--View the SQL statement that created the database
Show CREATE Database mydb;
--View all database names
show databases;
--View all table names
Show tables;
--Modify the encoding of the table, which must be written in UTF8, not written utf-8
ALTER TABLE classes DEFAULT CHARACTER set UTF8;
--Modify the encoding of the database
ALTER DATABASE mydb DEFAULT CHARACTER set UTF8;
--Modify the encoding of the table field, here two classname, the first classname refers to the original field name, the second classname refers to the field name to be modified
ALTER TABLE Classes Change className className VARCHAR () CHARACTER SET UTF8 COLLATE utf8_general_ci;--correct
ALTER TABLE Classes Change className className varchar (50)--correct, followed by the field's data type, here is VARCHAR (50)
ALTER TABLE Classes Change className className VARCHAR () character Set utf8;--correct
--Create a table and add a foreign key
--CREATE TABLE students (ID int primary key NOT null Auto_increment,classid int, stuname VARCHAR (), FOREIGN key (ClassId) REFERENCES classes (ID));
--View the index of the table
Show index from TABLE_NAME
--Add Index
CREATE INDEX S_name on students (STUNAME);
MySQL Related commands