Query for altering column to be nullabe not working [duplicate] - mysql

This question already has answers here:
How to add not null constraint to existing column in MySQL
(3 answers)
Closed 3 years ago.
I need to make column called start_date_data_id to be nullable.
I found this answer(Altering a column to be nullable) and tried to do it on described way.
Description of that column: (| start_date_data_id| bigint(20)| NO | MUL | NULL | |).
Query:
ALTER TABLE attenddb.company_group_user_settings
ALTER COLUMN start_date_data_id bigint(20) NULL;
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 'bigint(20) NULL' at line 1
Can someone tell me why is it not working?

Try this:
ALTER TABLE attenddb.company_group_user_settings
MODIFY start_date_data_id bigint(20) NULL;

Related

GENERATED keyword as column title in a mysql table [duplicate]

This question already has answers here:
How do I escape reserved words used as column names? MySQL/Create Table
(4 answers)
Closed 6 years ago.
I would like to create a table with GENERATED as column in MySQL version 5.7.16. When I try below query it is giving error:
create table madhu (RECORDID VARCHAR(255) NOT NULL, GENERATED INTEGER NOT NULL);
Below is the 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 'GENERATED INTEGER NOT NULL)' at line 1 0.000 sec
It looks GENERATED is reserved key word. Is there away to have GENERATED as column? If I change the column it works anyway.
To escape reserved keywords use backticks or choose a different column name.
create table madhu
(
RECORDID VARCHAR(255) NOT NULL,
`GENERATED` INTEGER NOT NULL
);

Unable to create table with column name "schemas" [duplicate]

This question already has answers here:
Is "key" a reserved word in MySqli? I'm getting an error
(2 answers)
Closed 6 years ago.
When I tried to execute following statement.
create table user_schemas (user_id varchar(255) not null, schemas varchar(255));
I am getting following 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 'schemas varchar(255))' at line 1
When I change the column name "schemas" to something else, it is working fine.
mysql> create table user_schemas (user_id varchar(255) not null, schemas varchar(255));
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 'schemas varchar(255))' at line 1
mysql>
mysql> create table user_schemas (user_id varchar(255) not null, rules varchar(255));
Query OK, 0 rows affected (0.01 sec)
Any idea on how to solve this problem??
If you want to use reserved words in the SQL syntax you must use Backticks (`) like:
create table user_schemas (
user_id varchar(255) not null,
`schemas` varchar(255)
);

sql tutorial script error [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
The SQL text that it tells you to copy and paste into phpMyAdmin's SQL page from this tutorial gives me 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 'TYPE=MyISAM' at line 6
This is the script:
CREATE TABLE `scores` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(15) NOT NULL DEFAULT 'anonymous',
`score` INT(10) UNSIGNED NOT NULL DEFAULT '0'
)
TYPE=MyISAM;
What am I getting wrong here?
It should be ENGINE=MyISAM instead of TYPE=MyISAM.
Yes. TYPE is not work for MyISAM.
**TYPE** must be **ENGINE** .
This is common problem!

error (1064) while creating table in mysql [duplicate]

This question already has answers here:
1064 error in CREATE TABLE ... TYPE=MYISAM
(5 answers)
Closed 9 years ago.
I am using mysql db(version 5.5) and using mysql query browser(v 1.1.5) .But when i try to create a simple table using query browser am getting following error:
CREATE TABLE `tstaks`.`employee` (
`empid` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY(`empid`)
)
TYPE = InnoDB;
mysql error no 1064
you have an error in your sql sytax,check the manual that corresponds to your mysqlserver version for right syntax to use
near type ='innoDB
TYPE needs to be ENGINE: 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)
);