---
title: "mysql 创建表并设置主键自增"
author: "fanjf"
date: "2012-04-09T11:54:32Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2012-04-09T11:54:32Z"
id: 1480217
url: "https://fanjf.iteye.com/blog/1480217"
---

01. mysql 创建表：
02. mysql&gt; create table user(
03. -&gt; userid int ( 4 ) primary key not  null  auto\_increment,
04. -&gt; username varchar(16 ) not  null ,
05. -&gt; userpassword varchar(32 ) not  null
06. -&gt; );
07. create table log(
08. logid int ( 4 ) primary key not  null  auto\_increment,
09. logtitle varchar(32 ) not  null ,
10. logcontent varchar(160 ) not  null ,
11. logtime datetime not null ,
12. userip varchar(64 ) not  null
13. );