zoukankan      html  css  js  c++  java
  • A MySQL 'create table' syntax example

     

    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.

  • 相关阅读:
    菜根谭#39
    菜根谭#38
    菜根谭#37
    菜根谭#36
    菜根谭#35
    菜根谭#34
    菜根谭#33
    菜根谭#32
    mysqli的使用
    mysql常用修改创建语句
  • 原文地址:https://www.cnblogs.com/hephec/p/4586864.html
Copyright © 2011-2022 走看看