MySQL Add delete primary key operation is very basic operation, the following will teach you MySQL add delete primary key method, if you are just contact the new MySQL database, may wish to see.
To modify the MySQL character set:
When installing mysql5.0, you can set the character set of MySQL, generally use the character set of UTF8
1, to view the establishment of the table "tablename" SQL statement
Show CREATE TABLE tablename;//view the SQL statement that establishes the table "tablename"
| Maos_mail_batch | CREATE TABLE ' Maos_mail_batch ' (
' ID ' varchar character set latin1 not NULL,
' batch_time ' varchar character set latin1 not NULL,
' batch_introduce ' varchar character set latin1 default NULL,
' Batch_sum ' int (one) default NULL,
' batch_state ' varchar (1) Character Set latin1 default NULL,
PRIMARY KEY (' ID ')
) Engine=myisam DEFAULT Charset=utf8 |
2, modify the database and table of the character set
ALTER DATABASE MAILDB default character set utf8;//modify the character set of the databases
ALTER TABLE mailtable default character set utf8;//modify the character set of a table
If you want to change the table default character set and all character columns (CHAR, VARCHAR, TEXT) to the new character set, use the following statement:
ALTER TABLE tbl_name CONVERT to CHARACTER SET charset_name;
Warning: The previous operation converted the column type between character sets. If you have a column that uses a character set (such as Latin1), but the stored value actually uses other character sets, such as UTF8, this is not what you want. At this point, you must do the following for such a column.
ALTER TABLE T1 Change C1 C1 BLOB;
ALTER TABLE T1 Change C1 C1 TEXT CHARACTER SET UTF8;
The reason this is possible is that the conversion does not occur when you convert to a BLOB column or convert from a BLOB column.
3, the primary key problem of MySQL:
Two primary keys for MySQL. Primary key and NOT null auto_incriment when you create a MySQL table, you add a primary key to a field Primary key when you insert data without the Insert primary key, MySQL automatically adds 0, However, when the second insert is not filled in the value of the MySQL database or the default add 0, will cause duplicate primary key, this is not possible. All when the primary key is defined, the primary key is filled with the value when the data is being insert.
When the MySQL table is established, a primary key not NULL auto_increment=1 is added to a field;
This is also a primary key. Starts with a 1 increase. This field is not required to fill in the value of the MySQL database will automatically fill in the value, will not appear primary key status.
Alter table TB Add primary key (ID);
Alter table TB change ID ID int (a) not null auto_increment=1;
4, delete from the growth of the primary key ID
First remove from growth in delete primary key
Alter table TB change ID ID int (10);//delete self-growth
Alter table TB Drop primary key;//Delete main build
The above is the MySQL add Delete primary key method introduction.