之前从网上找到《PHP+MYSQL网站设计入门实践》,第一部分是讲MySQL,今天基本看完了。以前大学的时候学过数据库,很多命令都还记得,所以学得快些。几个命令如下。
1.如何进入数据库
Root用户进入数据库的命令是#mysql –uroot –p123
2.DDL(数据定义语言)
创建数据库:Create database (if not exists) 数据库名
删除数据库:drop database (if exists) 数据库名
创建表格:create table 表名(列1 类型[选项],列2 类型[选项],……);
删除表格:drop table 表名
修改表格:改名(alter table t1 rename t2);
修改列的类型和名称(alter table t2 modify a tinyint not null,change b c char(5));
增加列(alter table t2 add d timestamp);(alter table t2 add b int auto_increment,add index(b);)