MySql简易笔记
1:安装http://download.mysql.cn/src/2006/0710/5543.html;
2:打开mysql的CMD
3:创建一个数据库及表:
mysql> create database bbs;
mysql> use bbs;
mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
-> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
4:查看:
show databases;
show tabales;
describe pet;
5:导出成*.sql文件
在系统cmd下使用命令:mysqldump -u root –p test > c:/test.sql
基本功能就此OK!
6:添加数据:
insert into pet value("lucy","lily","dog",'1',"2001-10-22","2009-1-4")
7:修改表
修改表名: alter table test rename test1
添加表列: alter table test add column name varchar(10)
删除表列: alter table test drop column name
修改表列类型:alter table test modify address char(10)
修改表列名: alter table test change column address address1 varchar(30)
8:添加自动增长的id
ALTER TABLE tablename DROP id;
ALTER TABLE tablename ADD id INT NOT NULL PRIMARY KEY AUTO_INCREMENT FIRST;
9:调整字段顺序