MySQL Related commands

Source: Internet
Author: User
Tags create index

--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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.