A MySQL 'create table' syntax example
2015-06-18 19:49
579 查看
I used to use MySQL every day for years, but over the last two years I haven't used it much. Today I needed to create a MySQL database table, and had to wonder for a few moments what the MySQLCREATE TABLE syntax was. Fortunately I have plenty of examples out here.
Here's a quick example of a MySQL "users" table:
drop table if exists users; # TODO: verify that this constraint creates a true index for performance create table users ( id int auto_increment not null, username varchar(32) not null, password varchar(16) not null, primary key (id), constraint unique index idx_users_unique (username) ) ENGINE = InnoDB;
If you need more examples of the MySQL create table syntax, or examples of the MySQL unique constraint syntax, check out my MySQL Nagios database design. It includes many (many) database tables, and as a result, it covers examples of many MySQL features.
相关文章推荐
- MySQL backup - How to backup a MySQL database
- ubuntu14源码安装mysql5.7
- MySQLdb autocommit
- mysql int(3)与int(11)的区别
- JDBC连接MySQL字符集错误解决办法
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s
- mysql主从同步配置步骤
- mysql排序后取第一条数据
- MySQL5.6之Index Condition Pushdown(ICP,索引条件下推)
- MySQLdb callproc 方法
- mysql group by中没有的字段 select中可以有
- 查看mysql数据库大小、表大小和最后修改时间
- ERROR 2003 (HY000): Can't connect to MySQL server on "host" (111)
- Mysql导出表结构及表数据 mysqldump用法
- MySQL用户及权限设置
- mysql 基本增删改查
- mysql主从复制(windows下)
- mysql重连的问题
- MySql怎样追踪用户操作(增删改)记录
- Pthon MySQLdb 的安装