syntax error in SQL statement (create table if not exists) [closed] - mysql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
CREATE TABLE IF NOT EXISTS ax_storage
(PID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(PID),
Playername VARCHAR(32),
Time INT(10), Type INT(6),
World VARCHAR(32);
What is wrong with this SQL statement?

You are missing to close a paranthesis at the end of the query
CREATE TABLE IF NOT EXISTS ax_storage
(
PID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(PID), Playername VARCHAR(32),
Time INT(10),
Type INT(6),
World VARCHAR(32)
); -- <- you were missing this one

you forgot ) in the end of query
CREATE TABLE IF NOT EXISTS ax_storage (PID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(PID), Playername VARCHAR(32), Time INT(10), Type INT(6), World VARCHAR(32));

Related

Why is there an Statment Error in MySQL [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have following Statment in MySQL and become every time this error(Screenshot):
CREATE TABLE orderstatus
(
OStatusID int NOT null PRIMARY KEY AUTO_INCREMENT,
OStatus varchar(30) null
(
I dont know why I become this error
Can you help me, please?
enter image description here
the close bracket is wrong, it should be ')'
try this
CREATE TABLE orderstatus
(
OStatusID int NOT null PRIMARY KEY AUTO_INCREMENT,
OStatus varchar(30) null
)
Below is right code Tested Successfully..
CREATE TABLE orderstatus
(
OStatusID int NOT null PRIMARY KEY AUTO_INCREMENT,
OStatus varchar(30) null
)[enter image description here][1]

What is wrong with this Create Table statement [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
please could you help me with this piece of code, I don't know what's wrong with it. It seems correct at simple glance but it just gets me #1064 syntax error. The MySQL version am running is 5.5
CREATE TABLE mytablename(
-> id SMALLINT NOT NULL AUTO_INCREMENT,
-> name VARCHAR(100) NOT NULL,
-> submission_date NOT NULL TIMESTAMP,
-> PRIMARY KEY (id)
-> )ENGINE=InnoDB;
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 '-> id SMALLINT NOT NULL AUTO_INCREMENT, -> name CHAR(100), ->
submission' at line 2
Remove those arrows and try escaping the column names with backticks:
CREATE TABLE mytablename(
`id` SMALLINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`submission_date` NOT NULL TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;

How can i turn a INT to VARCHAR in SQL [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm working on a database for my database class.
I have been trying to change the INT from SUBJECT_ID to VARCHAR.
This is the code I have been using but it keeps giving me errors:
ALTER TABLE COURSE
ALTER COLUMN SUBJECT_ID VARCHAR(11);
I also tried this:
SELECT CONVERT(VARCHAR(11),SUBJECT_ID) FROM COURSE;
and this is the table I'm working with:
CREATE TABLE COURSE
(COURSE_ID INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
SUBJECT_ID INT(11) NOT NULL,
COURSE_GRADE_LEVEL CHAR(2) NOT NULL,
FAC_ID INT NOT NULL,
FOREIGN KEY(FAC_ID) REFERENCES FACULTY(FAC_ID));
Any suggestions will be appreciated. Thanks.
Try:
ALTER TABLE COURSE MODIFY SUBJECT_ID VARCHAR(11);
select cast(subject_id as varchar(11)) as subject_id_str from course

You have an error in your SQL syntax [MariaDB] [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm getting this error while developing a javaEE application with MariaDB.
The error is:
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 'STARTING DATE, TITLE VARCHAR(255), CREATOR VARCHAR(255), LOCATION BIGINT, FORECA' at line 1
This is the problematic query:
CREATE TABLE EVENT
(
ID VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255),
ENDING DATE,
ISALLDAY TINYINT(1) default 0,
PUBLICEVENT TINYINT(1) default 0,
STARTING DATE,
TITLE VARCHAR(255),
CREATOR VARCHAR(255),
LOCATION BIGINT,
FORECAST BIGINT,
PRIMARY KEY (ID);
I can't figure out what is the problem...
You have a two typos:
STARTING - is a reserved word - use backticks
you forget closing parenthesis
This script should work:
CREATE TABLE EVENT
(
ID VARCHAR(255) NOT NULL,
DESCRIPTION VARCHAR(255),
ENDING DATE,
ISALLDAY TINYINT(1) default 0,
PUBLICEVENT TINYINT(1) default 0,
`STARTING` DATE,
TITLE VARCHAR(255),
CREATOR VARCHAR(255),
LOCATION BIGINT,
FORECAST BIGINT,
PRIMARY KEY (ID)
);

Trying to set up an auto_increment input system [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm new to this website so let me know if I'm doing something wrong.
I'm trying to make a system where every time a value is inserted into the table, it's given an ID. So the first one would be 21, next one 22, 23, and so on.
I'm fairly new at SQL so I threw this together hoping it'd work, and I figured I'd come here and ask for some help.
This is what I thought up:
CREATE TABLE _increment
(
ID int NOT NULL AUTO_INCREMENT,
user_id varchar(255) NOT NULL,
group_id varchar(255),
alias varchar(255),
notes varchar(255),
value varchar(255),
hash varchar(255),
function_id varchar(255),
PRIMARY KEY (ID)
)
INSERT INTO _increment
(`user_id`, `group_id`, `alias`, `hash`, `function_id`, `value`, `disabled`)
VALUES ('262', NULL, NULL, 'john', 'wewbsite.ca/', NULL, '0');
CREATE TABLE _increment
The main points were some syntax errors, namely a missing semicolon at the end of the CREATE TABLE statement
CREATE TABLE _increment
(
ID int NOT NULL AUTO_INCREMENT,
user_id varchar(255) NOT NULL,
group_id varchar(255),
alias varchar(255),
notes varchar(255),
value varchar(255),
hash varchar(255),
function_id varchar(255),
PRIMARY KEY (ID)
); -- this one was missing
and a wrong column name in the INSERT INTO statement
INSERT INTO _increment
(`user_id`, `group_id`, `alias`, `hash`, `function_id`, `value`, `notes`) -- not `disabled`
VALUES ('262', NULL, NULL, 'john', 'wewbsite.ca/', NULL, '0');
If one hasn't got a mysql server ready to experiment and learn then I can recommend sqlfiddle to test such statements.
I would use GO command after creating table (in SQL Server - I think there exists similar command in MySQL).
I see that in table definition you have NOTES column, but in INSERT INTO statement you have DISABLED column instead.