Issue with creating table from .sql file - mysql

I am attempting to run a sql file on a mysql at this address
https://github.com/articDrag0n/PrepApp/blob/master/sql/create_tables.sql
and I am getting an error
ERROR 1064 (42000) at line 20: 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 '(ID)
)' at line 11
How do I fix this

It is not your version. There is an error in the script. The create offerings should read (comma was missing after icon VARCHAR(255)):
DROP TABLE IF EXISTS offerings;
CREATE TABLE offerings(
id int NOT NULL AUTO_INCREMENT,
name VARCHAR(255),
moderator TEXT,
moderator_email TEXT,
description TEXT,
location TEXT,
peopleLimit INT,
days TEXT,
icon VARCHAR(255),
PRIMARY KEY (ID)
);

Related

mysql error for a create table statement from shell client

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

MySQL error 1064 table creation

This seems a fairly trivial problem but I am having no luck in running the following query:
create table if not exists tweet_data (
created_at DATETIME,
user_name VARCHAR(20),
retweet_count INT,
favourite_count INT,
tweet_followers_count INT,
is_retweet BOOLEAN,
tweet_source VARCHAR(256),
user_location VARCHAR(256),
tweet_mentioned_count INT,
tweet_ID VARCHAR(256) NOT NULL,
tweet_text VARCHAR(140),
UNIQUE (tweet_ID) );
When I run this I get the following error message:
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 '(20), retweet_count INT, favourite_count INT,
tweet_followers_count ' at line 3
When I hover over the error tag on line 3 it says:
Syntax error : unexpected '(' (opening parenthesis)
I'm sure this is a simple fix, any help would be great!
Turned out to be an error with mySQL Workbench
create table if not exists tweet_data (
created_at DATETIME,
user_name VARCHAR (20),
retweet_count INT,
favourite_count INT,
tweet_followers_count INT,
is_retweet BOOLEAN,
tweet_source VARCHAR(256),
user_location VARCHAR(256),
tweet_mentioned_count INT,
tweet_ID VARCHAR(256) NOT NULL,
tweet_text VARCHAR(140),
UNIQUE (tweet_ID) );
Man this code is running perfectly.
go to this link and check it your self
http://rextester.com/l/mysql_online_compiler

sql create table errors MySQL server version

write a sql sentence to create a table in MySQL
CREATE TABLE fb_web_user_feeds(id bigint not null primary key auto_increment,host_id bigint,,author varchar(64),time varchar(64),user_feed text)
BUT IT ERRORS:
pymysql.err.ProgrammingError: (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 'author varchar(64),time varchar(64),user_feed text)' at line 1")
could you please tell me the reason
It's because you have 2 commas here:
host_id bigint,,author varchar(64)
It should just be 1 comma making your syntax be:
CREATE TABLE fb_web_user_feeds(id bigint not null primary key auto_increment,host_id bigint,author varchar(64),time varchar(64),user_feed text)

Running SQL script gives syntax error

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;

Why am I getting a syntax error when trying to create a table? [duplicate]

This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 1 year ago.
I am trying to create a new table using the following:
CREATE TABLE onsale (
id INT AUTO_INCREMENT,
name VARCHAR(255),
desc TEXT,
image_file VARCHAR(255)
);
However, I keep getting an error:
ERROR 1064: (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB version for the right syntax to use near: 'desc TEXT, image_file VARCHAR(255))' at line 1
I don't see what is wrong with my syntax. It seems okay to me (obviously).
Can you tell me what I am doing wrong?
Thank you for your help.
The name you used for your column desc is a reserved word. You also need primary key (id):
CREATE TABLE onsale (
id INT AUTO_INCREMENT,
name VARCHAR(255),
description TEXT,
image_file VARCHAR(255),
primary key (id)
);