0

I tried to create a table named users by CREATE TABLE users (id INT, name CHAR);. Now, I can't start mysql from console, the error is as follows:

mysql: [ERROR] unknown option '--CREATE TABLE users (id INT, name CHAR);'.

Paweł Obrok
  • 22,568
  • 8
  • 74
  • 70

1 Answers1

-1

The CREATE TABLE statement is used to create a table in MySQL.

NOT NULL - Each row must contain a value for that column, null values are not allowed

DEFAULT value - Set a default value that is added when no other value is passed

UNSIGNED - Used for number types, limits the stored data to positive numbers and zero

AUTO INCREMENT - MySQL automatically increases the value of the field by 1 each time a new record is added

PRIMARY KEY - Used to uniquely identify the rows in a table. The column with PRIMARY KEY setting is often an ID number, and is often used with AUTO_INCREMENT

Each table should have a primary key column (in this case: the "id" column). Its value must be unique for each record in the table.

CREATE TABLE users(
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL
)
Rahul Kr Daman
  • 387
  • 3
  • 15