I am using xampp.
After creating a database
CREATE DATABASE University + use University
I create table by typing
CREATE TABLE Student
(
SNo INT NOT NULL,
SName VARCHAR(16) NOT NULL,
SAge INT NOT NULL,
SDepartment ENUM('CS', 'EE', 'Math', 'Physics') NOT NULL,
PRIMARY KEY (SNo)
);
But a beep is resulted and
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 'use University
CREATE TABLE Student
(
SNo INT NOT NULL,
Sname VARCHAR(16) NOT NULL,
SAg'
at line 2
is shown in command prompt. But I don't know what the syntax error is in this case.
I think the + is giving you syntax error. Try getting rid of it to separate these into two statements
CREATE DATABASE University
USE University
Related
Im trying to run the following from the mysql shell client:
MySQL localhost:33060+ ssl plaything SQL > CREATE TABLE areas (id SERIAL PRIMARY KEY, area_name VARCHAR);
and keep getting the following error:
ERROR: 1064: 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 ')' at line 1
where could I be going wrong?
solved by yoss:
try this: CREATE TABLE areas ( id int NOT NULL AUTO_INCREMENT, area_name varchar(255), PRIMARY KEY (id) );
varchar did not have number of characters specified in the original statement
This is a very simple piece of code using which I am trying to create a table of an entity Bank.
create table bank (
banknum integer(5) NOT NULL,
bankname varchar(20) NOT NULL,
primary key(banknum));
However, executing this gives an error:
Error Code: 1064 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 'create table bank ( banknum integer(5) NOT NULL,
bankname varchar(20) NOT NULL, ' at line 1
I do not understand where this syntax error is occurring.
create table bank (
banknum INT(5) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
bankname VARCHAR(20) NOT NULL);
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
I have written an sql script with the following contents :
CREATE DATABASE IF NOT EXISTS stock_trading;
USE stock_trading;
CREATE TABLE IF NOT EXISTS transactions(
user_name VARCHAR(30) NOT NULL,
passwrd BINARY(64) NOT NULL,
balance_cash BIGINT NOT NULL DEFAULT 100000,
PRIMARY KEY (user_name,passwrd),
)ENGINE=InnoDB;
and every time I try to run it in the SQL command prompt it keeps giving away the error as:
ERROR 1064 (42000) at line 5 in file: 'db_script.sql': 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 ')ENGINE=InnoDB' at line 5
the script appears to be correct but I don't know why it keeps giving this error.
Additional information:
Operating System : Arch Linux
Database : MariaDB
You have a stray comma at the end of your table definition:
PRIMARY KEY (user_name,passwrd),
^^^ remove this
Your full table definition:
CREATE TABLE IF NOT EXISTS transactions(
user_name VARCHAR(30) NOT NULL,
passwrd BINARY(64) NOT NULL,
balance_cash BIGINT NOT NULL DEFAULT 100000,
PRIMARY KEY (user_name, passwrd)
) ENGINE=InnoDB;
I have the following query for creating a table in my database but I am getting an error:
CREATE TABLE student (
accountNumber INT NOT NULL PRIMARY KEY,
firstName CHAR(20),
lastName CHAR(20),
courseID VARCHAR(6),
grade DOUBLE(3)
)
The error I am getting is:
ERROR 1064 (42000): 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 1
You dont need NOT NULL if declaring a Primary Key...because that key always needs to be available