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.
Related
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
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 6 years ago.
Improve this question
I have a code snippet from MYSQL that creates a 2 tables with a constrain between them plus some data to be inserted in one of the tables.
I would like to be converted equivalently to MSSQL. I tried migration but it keeps giving me an error on conversion and i can't figure out where is the problem as on mysql this code works fine.
CREATE TABLE `tbl_variable_types`
(
`variable_type_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`variable_type` varchar(10) DEFAULT NULL,
PRIMARY KEY (`variable_type_id`),
UNIQUE KEY `variable_type_id_UNIQUE` (`variable_type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
INSERT INTO `tbl_variable_types` VALUES
(1,'BOOL'),(2,'BYTE'),(3,'WORD'),(4,'DWORD'),
(5,'SINT'),(6,'INT'),(7,'DINT'),(8,'LINT'),(9,'USINT'),(10,'UINT'),
(11,'UDINT'),(12,'ULINT'),(13,'REAL'),(14,'LREAL'),(15,'STRING');
CREATE TABLE `tbl_variables`
(
`variable_tag_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique tag id to be used when calling variable in the code',
`variable_name` varchar(100) NOT NULL COMMENT 'Variable string name from the plc CASE SENSITIVE',
`variable_type` int(11) unsigned NOT NULL COMMENT 'The variable type from the twin table',
PRIMARY KEY (`variable_tag_id`),
UNIQUE KEY `variable_tag_id_UNIQUE` (`variable_tag_id`),
KEY `c_var_type_idx` (`variable_type`),
CONSTRAINT `c_var_type` FOREIGN KEY (`variable_type`)
REFERENCES `tbl_variable_types` (`variable_type_id`)
ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
How to translate this code to SQL Server?
Are you looking for below query
CREATE TABLE tbl_variable_types
(
variable_type_id int PRIMARY KEY NOT NULL Identity(1,1),
variable_type varchar(10) DEFAULT NULL
)
INSERT INTO tbl_variable_types VALUES (1,'BOOL'),(2,'BYTE'),(3,'WORD'),(4,'DWORD'),(5,'SINT'),(6,'INT'),
(7,'DINT'),(8,'LINT'),(9,'USINT'),(10,'UINT'),(11,'UDINT'),(12,'ULINT'),(13,'REAL'),
(14,'LREAL'),(15,'STRING');
CREATE TABLE tbl_variables
(
variable_tag_id int NOT NULL IDentity (1,1) PRIMARY KEY ,
variable_name varchar(100) NOT NULL,
variable_type int NOT NULL REFERENCES tbl_variable_types (variable_type_id),
);
For adding Comment of column
EXEC sp_addextendedproperty
#name = N'Description', #value = 'Hey, here is my description!',
#level0type = N'Schema', #level0name = yourschema,
#level1type = N'Table', #level1name = YourTable,
#level2type = N'Column', #level2name = yourColumn;
GO
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 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 creating table in mysql database but it is giving error...
CREATE TABLE IF NOT EXISTS `EC_TIMETABLE` (
`S_ID` VARCHAR(30) NOT NULL PRIMARY KEY,
`SKILLSET_ID` VARCHAR(30) NULL ,
START_DT DATETIME NULL,
END_DT DATETIME NULL,
REPEAT TINYINT(1) NULL,
ALL_DAY TINYINT(1) NULL,
CLASS_DURATION INT NULL,
COURSE_DURATION INT NULL,
REPEAT_TYPE VARCHAR(30) NULL,
REPEAT_EVERY INT NULL,
REPEAT_DAYS VARCHAR(100) NULL,
REPEAT_FROM DATE NULL,
REPEAT_TO DATE NULL,
COURSE_FEE INT NULL,
ATTENDEE_MIN INT NULL,
ATTENDEE_MAX INT NULL,
SEARCH_KEY TINYTEXT NULL,
FOREIGN KEY (`SKILLSET_ID` )
REFERENCES `EC_SKILLSET` (`S_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
But it giving 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 'REPEAT TINYINT(1) NULL, ALL_DAY TINYINT(1) NULL, CLASS_DURATION
INT NULL' at line 6
How to solve this one..
REPEAT is a Reserved Keyword. You can still use it but you need to wrap it with backticks.
`REPEAT` TINYINT(1) NULL,
MySQL Reserved Keywords List
I suggest that you don't use such keywords on the reserve list to avoid neck pain in the future.
I believe REPEAT is a keyword in MySQL. Try renaming your column.
First you shouldn't use REPEAT because this is reserved by mysql and secondly take a look at MySql Error 150 - Foreign keys because you have another error concerning foreign keys.
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 8 years ago.
im tearing my hair out over this one. A query is throwing an error:
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 'FROM, SUBJECT, DATE, READ, MAIL ) VALUES ( 'EJackson', 'dfdf', '1270974101', 'fa' at line 1
I printed out the query to see what could be the problem:
INSERT INTO db.tablename ( FROM, SUBJECT, DATE, READ, MAIL ) VALUES ( 'EJackson', 'dfdf', '1270974299', 'false', 'dfdsfdsfd' )
and finaly the structure consists of:
CREATE TABLE db.tablename (
`ID` int(12) NOT NULL auto_increment,
`FROM` varchar(255) NOT NULL,
`SUBJECT` varchar(255) NOT NULL,
`DATE` varchar(255) NOT NULL,
`READ` varchar(255) NOT NULL,
`MAIL` varchar(255) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I can't find anything wrong. Any help would be much appreciated.
In the insert statement, "FROM" is a keyword in SQL so you need to enclose it in backquotes like you have in your create table statement.
So it'll be like:
INSERT INTO db.tablename (`FROM`, `SUBJECT`, `DATE`, `READ`, `MAIL` ) VALUES ( 'EJackson', 'dfdf', '1270974299', 'false', 'dfdsfdsfd' )
Isn't FROM a reserved word in MySQL?