Simple data types MySQL +

type of data

Numeric
integer
int (m) four bytes (-21 billion to $ 2.1 billion) --- Java: int
BIGINT (m) eight-byte (18 th) --- java: long
float
float (m, d) the single-precision floating-point four bytes of 8-bit precision m number decimal number d Java ---: a float
double (m, d) 16-bit double precision floating point precision of eight bytes total number of d m decimals number --- java: float
fixed-point
float is always stored in the database are approximations, and the fixed-point the exact value is stored in
decimal (m, d) m < 65 d <30 and d <mm is the total number of d is the number of decimal places --- java: double
character
char (n): a fixed maximum length of 255 characters
to char the end of the storage spaces is not
a fixed length, so that regardless of the character is stored in several locations occupies two bytes n n positions also take
varcahr (n): fixed length up to 65,535 characters
varchar on the basis of fixed length representing a length of a few number of actual occupancy +1 into three four
text: a variable length up to 65,535 characters.
generally used in the development varchar if it must specify the length of the string stored in very large, we do not recommend the use of specified length text
date type of
data the Java date ---: java.sql.Date
time The Java Time ---: java.sql.Date
datatime date and time --- java: java.sql.Timesatmp
Modified timestamp automatic storage
MySQL operation

Create a table

TABLE the STUDENT the CREATE (
the SID the INT a PRIMARY KEY,
SNAME VARCAHR (20 is), the NOT NULL,
SEEX CHAR (. 3) the CHECK (SEX the IN ( 'M', 'F')),
)
to modify the table

Modify
ALTER TABLE STUDENT CHANGE SEEX SEX CHAR ( 4) NOT NULL CHECK (SEX IN ( ' M', 'F'));
rename table
ALTER TABLE STUDENT RENAME STUDENTS;
Delete column
ALTER TABLE STUDENT DROP SEX; - level data row use alter delete
to delete the table
DROP tABLE STUDENT; - above the table level data deleted using the drop
delete the database
DROP dATABASE ***;
MySQL's CRUD

Adding
INSERT INTO STUDENT (SNAME, SEX) VALUES ( 'XXX', ' male');
modify
UPDATA STUDENT SET SNAME = 'YYY' , SEX = ' F' WHERE SID = 1;
delete
DELETE FROM STUDENT WHERE SID = 1;
Query
SELECT * FROM STUDENT

Guess you like

Origin blog.51cto.com/14589001/2446843