MySQL Common Command Collation summary

Source: Internet
Author: User

#修改字段类型
ALTER TABLE ' TABLE_NAME ' modify column IP varchar (50);

#增加字段
ALTER TABLE ' table_name ' Add IP varchar (50);

#增加PRIMARY key (primary key index)
ALTER TABLE ' table_name ' ADD PRIMARY KEY (' IP ');

#添加UNIQUE (unique index)
ALTER TABLE ' table_name ' ADD UNIQUE (' IP ');

#添加INDEX (normal index)
ALTER TABLE ' table_name ' ADD INDEX IP (' ip ');

#添加联合索引
ALTER TABLE ' table_name ' ADD INDEX userip (' IP ', ' name ');

#添加FULLTEXT (full-text index)
ALTER TABLE ' table_name ' ADD fulltext (' column ');

#删除索引
ALTER TABLE ' TABLE_NAME ' drop index IP;

GRANT all privileges on * * to ' root ' @ ' 192.168.3.150 ' identified by
' MyPassword ' with GRANT OPTION;

#新增一个用户名test, password 123 user link host is localhost, can also be written as IP, or 192.168.0.% ( 192.168.0. Any), or% (do not restrict host)
Insert into Mysql.user (host,user,password,ssl_cipher,x509_issuer,x509_subject) VALUES ("localhost", "Test", Password ("123"), ', ', ', ');
#新增完成后刷新权限表
Flush privileges;

#授权相关

#授权所有数据库的权限给用户名为test密码为123的用户
Grant all privileges on * * to [e-mail protected] identified by ' 123 ';

#授权所有数据库的权限给用户名为test密码为123的用户, and test has permissions granted to other users
Grant all privileges on * * to [email protected] identified by ' 123 ' with GRANT OPTION;

#授权testdb数据库的select权限给用户名为test密码为123的用户
Grant Select on testdb.* to [e-mail protected] identified by ' 123 ';

#授权完成后刷新权限表
Flush privileges;

#字段类型

The column types of the numeric type include integer and floating-point categories.

Tinyint:1 byte very small positive integer with symbol: -128~127, unsigned: 0~255
Smallint:2 byte Small Integer, signed: -32768~32767, unsigned: 0~65535
Mediumint:3 byte medium-sized integer, signed: -8388608~8388607, unsigned: 0~16777215
Int:4 byte Standard Integer, signed: -2147483648~2147483647, unsigned: 0~4294967295
Bigint:8 byte Large Integer, signed: -9223372036854775808~9233372036854775807, unsigned: 0~18446744073709551615
Float:4 byte single-precision floating-point number, minimum non-0 value: +-1.175494351e-38, maximum non-0 value: +-3.402823466e+38
Double:8 byte double-precision floating-point number, minimum non-0 value: +-2.2250738585072014e-308, maximum non-0 value: +-1.7976931348623157e+308
DECIMAL (M, D): The m+2 byte is a floating-point number expressed as a string, and its range of values is variable, determined by the values of M and D.

Character type
One character, one byte, one kanji = 2 characters, 2 bytes

Char[(m)] M-byte fixed length
Varchar[(m)] M byte variable length, storage size is the actual length of bytes of input data
Tinyblod,tinytext 2^8-1 bytes l+1 bytes
Blob,text 2^16-1 byte l+2
Mediumblob,mediumtext 2^24-1 byte l+3
Longblob,longtext 2^32-1 byte l+4
ENUM (' value1 ', ' value2 ',...) 65,535 members 1 or 2 bytes
SET (' value1 ', ' value2 ',...) 64 members 1,2,3,4 or 8 bytes













MySQL Common Command Collation summary

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.