Home News Create Mysql Error 1064? Fix It Right Now

Create Mysql Error 1064? Fix It Right Now



Hope that if you get MySQL error 1064 on your machine, this user guide will help you solve it. ERROR 1064 (42000) mainly occurs when the syntax is set incorrectly, i.e. an error using the backtick character or creating a database without it can also cause an error if you use a hyphen in the name, for example B. Demo Table results in ERROR 1064 (42000). The database has been successfully created.



Here are the problems I see in your original script:

  1. Columns

    BLOB and TEXT must not have any DEFAULT value.

  2. TINYTEXT is the same as VARCHAR (255) , so you cannot specify a maximum length for the TINYTEXT field as it is already implied.

  3. A space is required between PRIMARYKEY . It should be PRIMARY KEY .

  4. mysql error 1064 create

    In the end, this is not a problem, but in your first CREATE TABLE statement, you have an odd spacing. If you change the ClientEmail line as follows, it becomes more readable:

Much better:

  ClientPhone CHAR (10) NOT EMPTY,ClientEmail TINYTEXT NON NULL, 

See the MySQL documentation for more information. After all these fixes, here are the working MySQL queries:

  CREATE DATABASE bankbase;USE the bank;    CREATE TABLE customer table (ClientID SMALLINT (15) NOT NULL DEFAULT 0,ClientFirstName VARCHAR (30) NOT NULL DEFAULT "Name",ClientLastName VARCHAR (30) NOT NULL DEFAULT "Last name",ClientPhone CHAR (10) NOT NULL,ClientEmail TINYTEXT NULL,ClientAddress TINYTEXT NON NULL,PRIMARY KEY (ClientID));CREATE branch table (BranchID SMALLINT (15) NOT NULL P   DEFAULT 0,BranchCity TINYTEXT NON NULL,BranchManagerFName VARCHAR (30) NULL DEFAULT "Branch manager name",BranchManagerLName VARCHAR (30) NULL DEFAULT "LAst Name of Branch Manager",BranchPhone CHAR (10) NOT NULL,BranchEmail TINYTEXT NULL,PRIMARY KEY (BranchID));    CREATE TABLE transaction table (TypeID SMALLINT (15) NOT NULL DEFAULT 0,Enter ENUM ('CHECK', 'SAVE') NON NULL.TransAmount DECIMAL NON NULL,TransDate TIMESTAMP NOT NULL,DOUBLE NOT ZERO balance,Primary key (TypeID)); 

If you hit create schema on this SQL script, you will find that it works!

Causes Of Error 1064

This may sound cryptic as it is a general error indicating a syntax problem in an SQL query statement. Since error 1064 can have several causes, we will look at the most common causes that lead to this error and show you how to fix them. Follow the instructions to keep your SQL queries updated and run correctly.

How To Fix MySQL Error 1064 (5 Methods)

If you already know what is causing the MySQL 1064 error, you can simply skip to the solution for your specific situation. However, if you do not know why the error occurred, askTry the simplest solution first.

In this case, we recommend that you test the five most likely fixes in the following order.



How do you create a new database in MySQL?

Follow these steps to create a MySQL database and MySQL user:
  1. From the command line, connect to MySQL as root user: mysql -u root -p.
  2. Enter the MySQL root password and press Enter.
  3. Enter \ q to exit the MySQL program.
  4. Enter the following command to log into MySQL as the user you just created.

How do you delete a database in MySQL?

Removing a MySQL or MariaDB Database

Start by listing all the databases on your server. Use the command “SHOW DATABASES;” in the MySQL console, as in the example above. Now copy the name of the database you want to delete. To drop a database, you need the DROP DATABASE command.

How do I view tables in MySQL?

To get a list of tables in a MySQL database, connect to the MySQL server using the MySQL client tool and enter the SHOW TABLES command. The optional FULL modifier displays the table type as the second output column.