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.
相关文档:
# MySQL-Front 5.1 (Build 4.2)
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE */;
/*!40101 SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES */;
/*!40103 SET SQL_NOTES='ON' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS */ ......
1. 安装mysql的时候选择字符集utf8
2. 安装结束后修改my.ini,有两个地方要修改,
[mysql] default-character-set=gbk
# The default character set that will be used when a new schema or table is
# created and no character set ......
我们知道用powerdesigner导出的sql文件后缀为'.sql';用phpmyadmin很容易导入MysQL数据库,但是用PHP怎么导入数据库呢?
我用powerdesigner设计一个数据库后导出sql文件(一个投票系统)为'vote.sql';
文件内容为(一些sql语句和注释):
/*======================= ......
首先,要下载一个连接mysql数据库的驱动程序: mysql-connector-java-3.0.15-ga-bin.jar, 这个驱动程序不需要做其它配置,也就是说,对于mysql数据库,不必像access或者oracle要建立odbc数据源。
其次,将上面的.jar文件加入到classpath环境变量中。
最后,就是写代码进行测试了。
主要代码如下:
......
注: 从MySQL从服务器的版本不能小于主服务器的版本 实验环境 Master Mysql服务器版本5.1.36,IP:192.168.128.130 Slave Mysql服务器版本5.1.36,IP:192.168.128.132 一. MySQL主服务器配置 1.建立授权用户 用法:grant replication slave on *.* to ‘用户名’@'主机’ identified by ‘密码’; mysql>grant replicatio ......