mysql 自增列的创建
1.建表时就创建自增列:
create table test
(
id int auto_increment primary key,
name varchar(20) not null,
password varchar(20) not null
);
insert into test values(null,'aa','aa');
insert into test values(null,'bb','bb');
注意:
插入语句时,自增列的值为NULL。
2、创建表格后添加: alter table table1 add id int auto_increment primary key 自增字段,一定要设置为primary key.
相关文档:
搞了很久。。终于发现原来是权限问题。。
2行命令搞定
grant all privileges on rogue.* to admin@localhost identified by 'admin' with grant option
grant all privileges on rogue.* to admin@'%' identified by 'admin' with grant option
经典了。。。
魔力私服网页端搞定咯~~ ......
MySQL导出和导入SQL脚本
导出sql脚本:
mysqldump -u 用户名 -p 数据库名 > 存放位置
mysqljump -u root -p test > c:\a.sql
导入sql脚本:
要建环境变量或者在bin的目录下,mysql这个命令才能识别。
test是你要导进去的数据库名字,要提前建好~~
mysql -u 用户名 -p 数据库名 < 存放位置
mysqljump -u ro ......
引自 http://www.itpub.net/thread-1034410-1-1.html
Mysql Explain 详解
一.语法
explain < table_name >
例如: explain select * from t3 where id=3952602;
二.explain输出解释
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type ......
添加字段的格式
ALTER [ONLINE | OFFLINE] [IGNORE] TABLE tbl_name alter_specification [, alter_specification] ...alter_specification: table_option ... | ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name ]
eg.
ALTER TABLE myTbl ADD COLUMN newItem VARCHAR(20) DEFAULT "0" ......