Search code examples
phpmysqldrupal-7

closing bracket expected" when creating table in mysql?


CREATE TABLE `actions` (
  `aid` varchar(255) NOT NULL DEFAULT '0'COMMENT
)

Here is the error Error

Static analysis:

1 errors were found during analysis.

A closing bracket was expected. (near ")" at position 76)

SQL query:

CREATE TABLE actions ( aid varchar(255) NOT NULL DEFAULT '0'COMMENT )

MySQL said: Documentation

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use

near ')' at line 3


Solution

  • you miss the comment string after COMMENT

     CREATE TABLE `actions` (
      `aid` varchar(255) NOT NULL DEFAULT '0' COMMENT 'myComment'
    )
    

    For more Information about the create table Syntax see the offical documentation

    column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY] [COMMENT 'string'] [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}] [STORAGE {DISK|MEMORY|DEFAULT}] [reference_definition] | data_type [GENERATED ALWAYS] AS (expression) [VIRTUAL | STORED] [UNIQUE [KEY]] [COMMENT comment] [NOT NULL | NULL] [[PRIMARY] KEY]