一、MySQL命令&语句
MySQL使用标准的SQL数据语言形式。
mysqladmin -u root -p create DATABASE
mysqladmin -u root -p drop DATABASE
mysql -u root -p 进入mysql控制台,可以执行简单的SQL命令
SHOW DATABASES;
use DATABASE;
SHOW TABLES;
SHOW COLUMNS FROM TABLE;
SHOW INDEX FROM TABLE;
ALTER TABLE testalter_tbl DROP i;
ALTER TABLE testalter_tbl ADD i INT;
ALTER TABLE testalter_tbl MODIFY c CHAR(10);
ALTER TABLE testalter_tbl CHANGE i j BIGINT;
ALTER TABLE testalter_tbl RENAME TO alter_tbl;
CREATE TABLE table_name (column_name column_type);
DROP TABLE table_name ;
INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN );
SELECT column_name,column_name FROM table_name [WHERE Clause] [OFFSET M ][LIMIT N]
UPDATE table_name SET field1=new-value1, field2=new-value2
[WHERE Clause]
DELETE FROM table_name [WHERE Clause]
SELECT field1, field2,...fieldN table_name1, table_name2...
ORDER BY field1, [field2...] [ASC [DESC]]
二、数据类型
TINYINT
SMALLINT
MEDIUMINT
INT或INTEGER
BIGINT
FLOAT
DOUBLE
DATE
TIME
YEAR
DATETIME
TIMESTAMP
CHAR
VARCHAR
TINYBLOB
TINYTEXT
BLOB
TEXT
MEDIUMBLOB
MEDIUMTEXT
LONGBLOB
LONGTEXT
三、MySQL 事务
Atomicity(原子性)
Consistency(稳定性)
Isolation(隔离性)
Durability(可靠性)
四、索引
实际上,索引也是一张表,该表保存了主键与索引字段,并指向实体表的记录。
索引大大提高了查询速度,同时却会降低更新表的速度。
CREATE INDEX indexName ON mytable(username(length));
ALTER table tableName ADD INDEX indexName(columnName)
DROP INDEX [indexName] ON mytable;