mysql tables and fields

Import database
files in a plurality of files stored in the data folder management system unified
classification database
installation and use the mysql
basic operations create show use drop database
basic operation create show desc drop table
Basic operation record insert into delete from update set select from

Today, content
database table remaining operations
encoding scheme described engine
operation database field
data type of database
constraints database field

Database configuration
by profiles unified configuration purposes unified management server mysqld client client
configured coding mysqld server for the database utf8 then re-create the default encoding are used utf8

modify table
alter table the old table rename the new table
to modify the field name
alter table table name change old field in the new field type (length)

modify field properties
alter table table name modify fields in the new type (length)

to create a table full syntax
create table table name (property name type (length) constraint)

database table engines create tale t11 (ID int) = XXX Engine

MySQL data types supported
type
tinyint 1 ~ byte -128
smallint the 2-byte ~ 32767 -32768
MEDIUMINT. 3 byte
int 4 bytes. 3 ~ -21,324,235
BIGINT. 8 bytes

constraint
unsigned unsigned
zerofill 0 filling

built table
mysql>: insert into tb1 values ( 128,32768,3768);
result 1273276732768
Conclusion integer determined by the length of bytes occupied by the length of the range can be customized
, but does not affect the range of bytes occupied
all the length of the integer variables are generally omitted write

Create Table TB2 (X tinyint unsigned);
INSERT INTO values TB2 (256), (-. 1);

Create Table Tb3 (X tinyint unsigned ZEROFILL);
INSERT INTO Tb3 values (10);


enumerate the set
enumeration with a set of options for providing a radio field enumeration only a set of 0-n can be selected from a plurality

build table
enum set default value is NULL
Create table TC1 (name VARCHAR (20 is), Sex enum ( 'M', 'F', 'wow'), hobbies set ( 'M' , 'F', 'wow'))
INSERT INTO TC1 values ( 'ruaki', 'Wow Wow', 'unknown');



Guess you like

Origin www.cnblogs.com/gongsla/p/11574973.html