Common statements in MySQL:
1: Create a table with self-growing primary key
DROP TABLE IF EXISTS user_login;
CREATE TABLE User_login (
user_id INT UNSIGNED not nullauto_increment,
User_name VARCHAR () DEFAULT NULL,
PRIMARY KEY user_id
) Engine=myisam auto_increment=0 DEFAULT Charset=utf8;
2: Modify table name
ALTER TABLE name RENAME present table name;
3: Add columns
ALTER table name ADD column name type length and so on [such as: VARCHAR (10)];
4: Modify Column Name
ALTER table name change column name is listed name type length and so on [such as: VARCHAR (10)]; ---Be sure to bring the type length information
5: Modify Column type length
ALTER Table name change column list name type length;
6: Delete Columns
ALTER TABLE column name DROP column name;
7: Modify the character set of the database UTF8
ALTER DATABASE test DEFAULT CHARACTER SET UTF8;
8: Modify the character set of the table UTF8
ALTER TABLE user_login DEFAULT CHARACTER SET UTF8;
9: Modify the existing table primary key self-growth (the original key is not set), only for future data to take effect, the existing data is invalid, existing data self-growth has not been resolved
ALTER table name change primary key column ID INT auto_increment;
10: Data encryption
A) Password function
such as: INSERT into User_login (User_name,user_password) VALUES (' Shark ', password (' qweasdzxc '));
The saved data is: Shark, *e9d8702e5ce97f00a17a75241c04a013b407a1a6
In particular, it is necessary to ensure the effective size of the encrypted field length, I here 9 characters 30 bit is not enough, I directly increase to 100, this specific bit with the encryption algorithm, post-study
Select decryption: SELECT * from User_login WHERE user_password=password (' qweasdzxc ');
b) MD5 encryption
INSERT into User_login (User_name,user_password) VALUES (' Kok ', MD5 (' qweasdzxc '));
The saved data is: KOK,315EB115D98FCBAD39FFC5EDEBD669C9
There is a certain difference between the character format generated by the password function encryption, or the encryption algorithm.
SELECT * FROM User_login WHERE user_password= MD5 (' qweasdzxc ');
The usual sentence collation in MySQL