View MySQL's encoding format

Source: Internet
Author: User

1. View the database encoding format

 like ' Character_set_database ';

2. View the encoding format of the data table

Create Table < table name >;

3. Specify the character set of the database when creating the database

Create Database < database name >characterset UTF8;

4. Specify the encoding format of the data table when creating the data table

Create TableTb_books (Namevarchar( $) not NULL, PriceDouble  not NULL, Bookcountint  not NULL, authorvarchar( $) not NULL)defaultCharSet=UTF8;

5. Modify the encoding format of the database

Alter Database < database name >characterset UTF8;

6. Modify the data table encoding format

Alter Table < table name >characterset UTF8;

7. Modify the field encoding format

 alter  table  <  table name >  change <  field name >  <  field name >  <  type >  character  set   UTF8;  alter  table  user  change username username varchar  ( Span style= "color: #800000; Font-weight:bold ">20 ) character  set  UTF8 not  null ; 

8. Add a FOREIGN key

Alter TableTb_productAdd constraintFk_1Foreign Key(Factoryid)Referencestb_factory (Factoryid);Alter Table <Table name> Add constraint <FOREIGN Key Name> Foreign Key<Field name> REFERENCES <Appearance table name><Field name>;

9. Delete foreign keys

Alter Table Drop Foreign Key Fk_1; Alter Table < table name >dropforeignkey< foreign key name >;

View MySQL's encoding format

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.