how do you create a table in mysql command line code example

Example 1: create table in mysql

# Creates a Simple User table
# Uses an auto-incrementing primary key as userId 

CREATE TABLE user (
    userId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(100),
    password VARCHAR(100) 
) ENGINE=InnoDB;

Example 2: how to create a table in mysql

-- 'CREATE TABLE' followed by the name of the table. 
-- In round brackets, define the columns.
CREATE TABLE `test_table` 
(
  id INT(10) PRIMARY KEY,			
  username VARCHAR(50) NOT NULL
);

Tags:

Sql Example