Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have created a MySQL database in which I have successfully executed the following query:
CREATE TABLE `Person`
(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '',
`country` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
which created a table.
Now I want to create identical table in an Oracle c11 database. Server and database are ready to take queries, however when I use the same query from MySQL I get syntax errors. How should this query look in Oracle database? I use Oracle SQL Developer.
Error starting at line : 1 in command - Error report - SQL Error: ORA-00907: brak prawego nawiasu 00907. 00000 - "missing right parenthesis"
This is what the query should look like
CREATE TABLE Person (
id number NOT NULL PRIMARY KEY ,
name varchar(20) DEFAULT '' NOT NULL,
country varchar(20) DEFAULT NULL
);
You need to create sequence and trigger for auto-increment or increase this manually in your code by calling sequence.nextval
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
create table dept(
Deptno integer NOT NULL PRIMARY KEY Departmentnumber,
Dname varchar(20) NOT NULL Nameofdepartment,
Loc varchar(10) NOT NULL Locationofdepartment
);
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 'Departmentnumber,Dname varchar(20) NOT NULL
Nameofdepartment,Loc varchar(10) NOT' at line 1
The issue is that you try to provide aliases to your column names, but you shouldn't, at least, not at the creation of the table:
create table dept(
Deptno integer NOT NULL PRIMARY KEY,
Dname varchar(20) NOT NULL,
Loc varchar(10) NOT NULL
);
You can use those aliases in select commands, but not in create table commands.
See more about the syntax of create table in the documentation.
You cant create an alias for columns when creating a table. Only when select-ing from it.
Remove the aliases and the query should work:
create table dept(Deptno integer NOT NULL PRIMARY KEY ,Dname varchar(20) NOT NULL ,Loc varchar(10) NOT NULL );
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;
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
mysql> CREATE TABLE DEPARTMENT
-> (
-> "ID" NUMBER,
-> "NAME" VARCHAR2(30),
-> PRIMARY KEY ("ID")
-> )engine-INNODB;
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 '"ID" NUMBER, "NAME" VARCHAR2(30), PRIMARY KEY
("ID") )engine-INNODB' at line 3
Can someone tell me what is that I am doing wrong here!!!!
The column names should not be in double quotes, and the database engine should use an "=" sign rather than a hyphen.
try this
CREATE TABLE `DEPARTMENT` (
`ID` int(6) NOT NULL auto_increment,
`NAME` varchar(30) NOT NULL default '',
PRIMARY KEY (`id`)
)
ENGINE=MyISAM AUTO_INCREMENT=1;
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
CREATE TABLE WLPortfolio
(
symbolID MEDIUMINT NOT NULL AUTO_INCREMENT,
symbol_userID MEDIUMINT NOT NULL,
symbol default NULL,
holding default NULL,
amount decimal(12,2) default NULL,
PRIMARY KEY (symbolID)
);
I am receiving this error when I try to import my database into phpMyAdmin as well as via ssh (corresponding code above):
ERROR 1064 (42000) at line 33: 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 'default NULL,
holding default NULL,
amount decimal(12,2) default NULL,
' at line 5
The partition in error is the decimal data type. To my knowledge decimal wat I have done should keep the "amount" value 12 characters long with the decimal values going into 2 characters. Which I believe is correct syntax, yet I still receive this error.
I have tried changing around the default value if for some reason this was causing the error or if compatibility issue was an error. But to no avail.
Any help with this would be greatly appreciated.
Completely missed declaring values holding and symbol, rookie mistake -_- Thanks guys
Define types for all fields.
CREATE TABLE WLPortfolio
(
symbolID MEDIUMINT NOT NULL AUTO_INCREMENT,
symbol_userID MEDIUMINT NOT NULL,
symbol MEDIUMINT default NULL,
holding MEDIUMINT default NULL,
amount decimal(12,2) default NULL,
PRIMARY KEY (symbolID)
);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This is my table definition:
CREATE TABLE IF NOT EXISTS `sms_data_updated` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_sms_received` int(10) unsigned DEFAULT NULL,
`sender_name` varchar(50) NOT NULL,
`sender_number` char(14) NOT NULL,
`key_word` varchar(20) NOT NULL,
`message_content` varchar(160) NOT NULL,
`date_received` datetime NOT NULL,
`date_inserted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`categories` varchar(100) NOT NULL,
`Division` varchar(30) NOT NULL,
`location_name` varchar(80) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
And when use the following INSERT statement:
INSERT INTO sms_data_updated (id_sms_received, sender_name, sender_number, key_word, message_content, date_received, Division, location_name)
VALUES (1,Shahriar Khondokar,+1726740333,,This is message content1. I need help1.,2012-10-16 10:11:09,Barisal,Borishal)
I am getting the following error message:
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 'Khondokar,+8801726740333,,This is message content1. I need help1.,2012-10-16 10:' at line 1
Any idea why?
string values must be wrap with single quote
VALUES(1,'Shahriar Khondokar','+172674033','This is message content1.',...)
Strings like Shahriar Khondoka needs quotes around it. Like this:
INSERT INTO sms_data_updated (id_sms_received, sender_name, sender_number, key_word, message_content, date_received, Division, location_name, Latitude, Longitude)
VALUES (1,'Shahriar Khondokar',rest of columns...)
It looks like you have a hanging comma after the location_name.
You have a different number of values as the amount of rows you are inserting into in the query. This could be causing an issue.