sql create table errors MySQL server version - mysql

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)

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

#1064, xammp, phpMyAdmin, MYSQL - Why have I an error in mySQL syntax?

#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 ') VIRTUAL,
`title_type` VARCHAR(45) NULL DEFAULT null,
PRIMARY KEY (`id`))' at line 2
Here is a part of script:
CREATE TABLE IF NOT EXISTS `sggis`.`maps_type` (
`id` INT GENERATED ALWAYS AS () VIRTUAL,
`title_type` VARCHAR(45) NULL DEFAULT 'yandex',
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SQL says that problem is in the 2nd line, but i can't find it.
Code generated by MySQL Workbench.
When using VIRTUAL columns you need to specify the expression
Any legal, deterministic expression which can be calculated is
permitted, with the following exceptions:
Your expression is blank.

Create MySQL Database with Xampp

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

Error 1064 when updating a table

When updating a table I get an error:
My table is
speech
values:
no speec check
1 45 0
and the structure is :
1 -no int(100) No None AUTO_INCREMENT Browse distinct values Change Drop Primary Unique Index Fulltext
2- speec varchar(100) latin1_swedish_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
3 - check int(100) No None Browse distinct values Change Drop Primary Unique Index Fulltext
when updating using the command :
UPDATE speech set check=1 where no=1
I get the 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 'check=1 where no=1' at line 1
Please help me in this issue
CHECK is a reserved, word http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
You need to escape it using backtics as
UPDATE speech set `check`=1 where no=1

Insert Column Name into Table if Column Name does not already exist

IF COL_LENGTH('Characters', 'name') IS NULL
BEGIN
ALTER TABLE `Characters` ADD `name` INT(32) UNSIGNED NOT NULL;
END
I am trying to write some sql that will insert a column name into the table "Characters" if it is not already existant, however I am getting errors which I do not understand (quite new to SQL) and I could use some help understanding why it is not working. I have gotten the IF part from another Question, and the ALTER part from the DBMS I'm using, PhpMyAdmin 2.11.4.
It is using MySQL 5.6 apparently and this is the error:
MySQL said: Documentation
#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 'IF COL_LENGTH('Characters', 'name') IS NULL
BEGIN
ALTER TABLE `Characters` AD' at line 1