SQL - "Default" when creating a table - is it neccessary?

J.Zil

Looking at examples of a standard SQL layout I see this:

CREATE TABLE IF NOT EXISTS siteUser (
  id int(11) AUTO_INCREMENT PRIMARY KEY,
  email varchar(64) NOT NULL UNIQUE KEY,
  password varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT;

What is th purpose of the "DEFAULT" at the end of specifying the engine? Is there any need for it? I tried to find an explanation of it on tutorial websites but I didn't have any luck.

James

Rahul Tripathi

It is used to set ENGINE=InnoDB as the default engine. So one way is to either remove the Engine = INNODB from your create table statement

CREATE TABLE IF NOT EXISTS siteUser (
  id int(11) AUTO_INCREMENT PRIMARY KEY,
  email varchar(64) NOT NULL UNIQUE KEY,
  password varchar(255) NOT NULL
)

DEMO

Or the other way which GolezTrol has suggested:

CREATE TABLE IF NOT EXISTS siteUser (
  id int(11) AUTO_INCREMENT PRIMARY KEY,
  email varchar(64) NOT NULL UNIQUE KEY,
  password varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT charset = utf8;

DEMO

From the Manual: InnoDB as the Default MySQL Storage Engine

In previous versions of MySQL, MyISAM was the default storage engine. In our experience, most users never changed the default settings. With MySQL 5.5, InnoDB becomes the default storage engine. Again, we expect most users will not change the default settings. But, because of InnoDB, the default settings deliver the benefits users expect from their RDBMS: ACID Transactions, Referential Integrity, and Crash Recovery.

However if you want to make the INNODB as your deafult engine then there is one other way:

Under [mysqld] section in your ini file, add:

default-storage-engine = innodb

It is there in /etc/my.cnf

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SQL Error when creating a table

From Dev

Having a default expression when creating a table in oracle

From Dev

SQL Server: when it's neccessary to use functions/procedures and not queries?

From Dev

Is it neccessary if query runs table will be filled?

From Dev

creating a table with default value

From Dev

How to restrict the length of INTEGER when creating a table in SQL Server?

From Dev

SQL: error when creating a foreign table that has an enum column

From Dev

EF Requiring primary key when creating a new entry in sql table

From Dev

"Missing Keyword" When creating a table in Oracle SQL Developer

From Dev

Best practices for asserting some condition in SQL when creating a table?

From Dev

How to restrict the length of INTEGER when creating a table in SQL Server?

From Dev

PhpMyAdmin SQL code not showing up when creating new database and table

From Dev

SQL, Why do I get this error when creating the reports table?

From Dev

Creating Table in Oracle, SQL

From Dev

Creating Table in Oracle, SQL

From Dev

Error creating table in SQL

From Dev

Creating table sql failed

From Dev

SQL Creating a table

From Dev

Default permission when creating a folder

From Dev

'invalid for creating a default constraint' error when trying to add a constraint to an existing table

From Dev

Is it possible to set a default value for a column when creating a table using ASP.net EF 5 code first?

From Dev

How to use default primary key as a sequence value when creating table for oracle database columns

From Dev

setting default value while creating table in SQLite

From Dev

creating table that replaces '-' with default value during insertion

From Dev

error when creating a partitioned table

From Dev

error when creating table in hive

From Dev

Creating a table using dynamic sql

From Dev

SQL dateformat while creating table

From Dev

Creating a table using dynamic sql

Related Related

  1. 1

    SQL Error when creating a table

  2. 2

    Having a default expression when creating a table in oracle

  3. 3

    SQL Server: when it's neccessary to use functions/procedures and not queries?

  4. 4

    Is it neccessary if query runs table will be filled?

  5. 5

    creating a table with default value

  6. 6

    How to restrict the length of INTEGER when creating a table in SQL Server?

  7. 7

    SQL: error when creating a foreign table that has an enum column

  8. 8

    EF Requiring primary key when creating a new entry in sql table

  9. 9

    "Missing Keyword" When creating a table in Oracle SQL Developer

  10. 10

    Best practices for asserting some condition in SQL when creating a table?

  11. 11

    How to restrict the length of INTEGER when creating a table in SQL Server?

  12. 12

    PhpMyAdmin SQL code not showing up when creating new database and table

  13. 13

    SQL, Why do I get this error when creating the reports table?

  14. 14

    Creating Table in Oracle, SQL

  15. 15

    Creating Table in Oracle, SQL

  16. 16

    Error creating table in SQL

  17. 17

    Creating table sql failed

  18. 18

    SQL Creating a table

  19. 19

    Default permission when creating a folder

  20. 20

    'invalid for creating a default constraint' error when trying to add a constraint to an existing table

  21. 21

    Is it possible to set a default value for a column when creating a table using ASP.net EF 5 code first?

  22. 22

    How to use default primary key as a sequence value when creating table for oracle database columns

  23. 23

    setting default value while creating table in SQLite

  24. 24

    creating table that replaces '-' with default value during insertion

  25. 25

    error when creating a partitioned table

  26. 26

    error when creating table in hive

  27. 27

    Creating a table using dynamic sql

  28. 28

    SQL dateformat while creating table

  29. 29

    Creating a table using dynamic sql

HotTag

Archive