Creating a table in MySQL results in error 1064. I do not have restricted words for table name.
mysql> create database NamesInc
-> ;
Query OK, 1 row affected (0.10 sec)
mysql> create table NameInfo(
-> Name_ID NUMBER(8),
-> Language VARCHAR2(10),
-> Status VARCHAR2(10),
-> Standard VARCHAR2(10),
-> Place_ID Number(8) NOT NULL,
-> Supplier_ID NUMBER(8) NOT NULL,
-> Date Supplied DATE,
-> PRIMARY KEY (Name_ID),
-> );
Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NUMBER(8),
Language VARCHAR2(8),
Status VARCHAR2(10),
PL' at line 2
Please let me know if I can provide additional information.
After create db statement do:
USE NamesInc;
create table NameInfo(
Name_ID INT(8),
Language VARCHAR(10),
Status VARCHAR(10),
Standard VARCHAR(10),
Place_ID INT(8) NOT NULL,
Supplier_ID INT(8) NOT NULL,
Date_Supplied DATE,
PRIMARY KEY (Name_ID)
);
Related
I am having a basic trigger syntax error. I am a beginner in mysql. Please help me.
I am having two tables.
Table 1 -
MariaDB [lab5]> create table library_2
-> (id int AUTO_INCREMENT primary key,
-> Book_name varchar(20),
-> Details varchar(50));
Table 2 -
MariaDB [lab5]> create table library_audit2
-> (id int AUTO_INCREMENT primary key,
-> Book_Name varchar(20) not null,
-> Details varchar(50) default null,
-> change_date date,
-> library_id int,
-> foreign key(library_id) REFERENCES library_2(id));
Trigger -
MariaDB [lab5]> DELIMITER $$
MariaDB [lab5]> create trigger BeforeLibraryDelete
-> BEFORE DELETE
-> ON library_2 FOR EACH ROW
-> BEGIN
-> delete from library_audit2 lib where lib.library_id=OLD.id;
-> END $$
The error -
#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 'lib where lib.library_id = :old.id;
END' at line 5
What is the error at line 5 ?
Your delete needs to specify the table to delete from:
delete lib
-------^ the table alias goes between the `delete` and the `from`
from library_audit2 lib
where lib.library_id = OLD.id;
I'm trying to create a table Order but somehow I am encountering the error code below:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Order(
OrderId int,
CustId int,
OrderDate datetime,
RequiredDate datetime,
Shipp' at line 1
I use the following code to create my table:
create table Order(
-> OrderId int,
-> CustId int,
-> OrderDate datetime,
-> RequiredDate datetime,
-> ShippedDate datetime,
-> Status varchar(12),
-> Comments varchar(255)
-> );
We don't need to set primary key or foreign key but I don't know what went wrong with my code. Please advice thanks!
Thanks #jarlh I didn't know it was a reserve word. I just started SQL.
I have created table like this
CREATE TABLE profile_contact
(
profile_id INT UNSIGNED NOT NULL,
service CHAR(20) NOT NULL,
contact_name CHAR(25) NOT NULL,
);
Then latter I want to insert the rows from mysql
mysql> INSERT INTO profile_contact
-> (profile_id,service,contact_name)
-> VALUES
-> (1,AIM,user1-aimid),
-> (1,MSN,user1-msnid),
-> (2,AIM,user2-aimid),
-> (2,MSN,user2-msnid),
-> (2,Yahoo,user2-yahooid)
-> (4,Yahoo,user4-yahooid);
But I got error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(4,Yahoo,user4-yahooid)' at line 9
I have followed standard INSERT INTO VALUES syntax.What is wrong?
Your script is missing a comma after the second last value (2,Yahoo,user2-yahooid) and hence, the error. Below should work:
CREATE TABLE profile_contact(
profile_id INT UNSIGNED NOT NULL,
service CHAR(20) NOT NULL,
contact_name CHAR(25) NOT NULL
);
INSERT INTO profile_contact
-> (profile_id,service,contact_name)
-> VALUES
-> (1,'AIM','user1-aimid'),
-> (1,'MSN','user1-msnid'),
-> (2,'AIM','user2-aimid'),
-> (2,'MSN','user2-msnid'),
-> (2,'Yahoo','user2-yahooid'),
-> (4,'Yahoo','user4-yahooid');
P.S. last column in CREATE statement should not have comma after it, however, I believe it's not the full CREATE script. Also, values like AIM etc should be enclosed in quotes.
Here's the SQL Fiddle.
I try to create a table in MySQL:
mysql> create table order ( ID varchar(30) not null,
-> Cname varchar(100) not null,
-> name varchar(30),
-> Type varchar(30),
-> primary key(ID, Cname));
but an error occured:
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'order ( ID varchar(30) not null, Cname
varchar(100) not null, name varchar(30), ' at line 1
I have checked for thousand time and I still find no error here.
Can anyone help me?
Its is because of the table name order.
There is an order by reserved word. Change the table name and it will work fine.
If you want order as table name use back ticks around the table name. It will workfine
Hello i am having an issue when trying to create a table inside of my database webhostc_MyRadContactForm
When i try to execute the statement below in phpMyAdmin i get this error
CREATE TABLE Contacts (
-> ContactID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> ContactName VARCHAR(100),
-> ContactEmail VARCHAR(100),
-> ContactLeastFavoriteColor VARCHAR(10)
-> ContactDateCreated DATETIME
-> );
#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 '-> ContactID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> ContactName VARCHA' at line 2
Also phpMyAdmin flags these lines:
My server is running: 10.0.22-MariaDB
You are missing a comma just after ContactLeastFavoriteColor VARCHAR(10) and those arrows, ->, are not supposed to be there. The following is the correct syntax for creating your table:
CREATE TABLE Contacts (
ContactID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
ContactName VARCHAR(100),
ContactEmail VARCHAR(100),
ContactLeastFavoriteColor VARCHAR(10),
ContactDateCreated DATETIME
);
Good luck!!
There are two problems:
Those -> symbols aren't part of SQL syntax. They're the prompts that the MySQL monitor prints when you enter a multi-line query. You can't copy them into PhpMyAdmin.
You're missing a comma at the end of the ContactLeastFavoriteColor line.