mysql 创建表并设置主键自增
mysql 创建表:
mysql> create table user(
-> userid int(4) primary key not null auto_increment,
-> username varchar(16) not null,
-> userpassword varchar(32) not null
-> );
create table log(
logid int(4) primary key not null auto_increment,
logtitle varchar(32) not null,
logcontent varchar(160) not null,
logtime datetime not null,
userip varchar(64) not null
);
相关文档:
安装好mysql后,在使用mysq时,出现了如下问题.
java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306?
at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:327)
at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
at org.gjt.mm.mysql.jdbc2 ......
一、MySql简介概要
MySQL是一个小型关系型数据库管理系统,开发者为瑞典MySQL AB公司,后来
被Sun公司收购,现在正在被甲骨文收购,支持FreeBSD、Linux、MAC、Windows
等多种操作系统 与其他的大型数据库例如Oracle、DB2、SQL Server等相比功能稍弱
一些 题外话:Postgresql&n ......
转帖请注明出处,并保持文章的完整性。
对MySQL数据库来说,同一时刻,在同一个连接(connection)上,只允许进行一个操作(query,etc.),如果你的程序是多线程的,并且你在多个线程中都会利用同一个connection对数据库进行操作,那么,就有可能发生问题。
例如,你可能会收到“Commands out of sync”的错误 ......
使用mysql时,通常表中会有一个自增的id字段,但当我们想将表中的数据清空重新添加数据时,希望id重新从1开始计数,用以下两种方法均可:
方法一:
alter table tablename drop column id;
alter table tablename add id mediumint(8) not null primary key auto_increment first;
方法二:
alter table tab ......
require() 与 require_once()
通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require
所指定引入的文件,如果出现错误是致命的。
nclude() 与 include_once()
&n ......