error while importing an sqlto phpMyAdmin db - mysql

I want to import an SQL file to my phpMyAdmin database, the file contains tables about a restaurant application and a table about the admin login, but I have 2 unexpected errors, I really don't see what is exactly wrong with that?. here is the error message:
Static analysis:
2 errors were found during analysis.
An opening bracket followed by a set of values was expected. (near "CREATE" at position 285)
Unexpected token. (near "CREATE" at position 285)
SQL query:
-- -- Déchargement des données de la table `operation` --
INSERT INTO `operation` (`numop`, `numcp`, `prenom`, `nom`, `type`, `numcp2`, `mentant`, `date`) VALUES
-- -------------------------------------------------------- --
-- Structure de la table `reclamation` --
CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL
,`id` varchar(8) NOT NULL
,`prenom` varchar(30) NOT NULL
,`nom` varchar(30) NOT NULL
,`text` text NOT NULL
,`date` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
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 'CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL,
`id` varchar(8) NO' at line 14
CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL,
`id` varchar(8) NOT NULL,
`prenom` varchar(30) NOT NULL,
`nom` varchar(30) NOT NULL,
`text` text NOT NULL,
`date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

There are no values after VALUES in operation insertion query.
This error points on create because this is the next to the insertion and it expected to be values but actually is CREATE ...
It seems the values cutted off, make sure to separate between queries with ;
INSERT INTO `operation` (`numop`, `numcp`, `prenom`, `nom`, `type`, `numcp2`, `mentant`, `date`) VALUES
-- Structure de la table reclamation --
CREATE TABLE `reclamation` (
`numrec` int(11) NOT NULL
,`id` varchar(8) NOT NULL
,`prenom` varchar(30) NOT NULL
,`nom` varchar(30) NOT NULL
,`text` text NOT NULL
,`date` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;

Related

ERROR 1067 (42000): Invalid default value for 'date_time' in MySQL

I am fairly new and was trying to upload a sql dump file which was working perfectly on my local machine, into a cloud 9. But on importing the file i am getting this error
ERROR 1067 (42000): Invalid default value for 'date_time'
The sql command in the dump file thats giving this error is
--
-- Table structure for table `history`
--
CREATE TABLE `history` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`action` varchar(4) NOT NULL,
`symbol` varchar(20) NOT NULL,
`company` varchar(255) NOT NULL,
`shares` int(11) NOT NULL,
`price` decimal(65,4) NOT NULL,
`total` decimal(65,4) NOT NULL,
`date_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `history`
--
any help would be appreciated
You cannot use CURRENT_TIMESTAMP on update. Instead, change it to a TIMESTAMP.

error while importing .sql to phpMyAdmin db

I want to import an SQL file to my phpMyAdmin database, the file contains tables about a restaurant application and a table about the admin login, but I have 2 unexpected errors, I really don't see what is exactly wrong with that?. here is the error message:
2 errors were found during analysis.
An opening bracket followed by a set of values was expected. (near "CREATE" at position 109)
Unexpected token. (near "CREATE" at position 109)
SQL query:
INSERT INTO `adminlogin` (`id`, `Username`, `Password`, `right`) VALUES (1, 'admin#gmail.com', '123', 1), CREATE TABLE IF NOT EXISTS `tbl_food` ( `id` int(11) NOT NULL AUTO_INCREMENT, `food_type` varchar(50) NOT NULL, `food_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1
MySQL said: Documentation
#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 'CREATE TABLE IF NOT EXISTS `tbl_food` (
`id` int(11) NOT NULL AUTO_INCREMENT,
' at line 6
and here is the two tables that show errors. Any insight on that? thank you
CREATE TABLE IF NOT EXISTS `adminlogin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Username` varchar(100) NOT NULL,
`Password` varchar(50) NOT NULL,
`right` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `adminlogin`
--
INSERT INTO `adminlogin` (`id`, `Username`, `Password`, `right`) VALUES
(1, 'admin#gmail.com', '123', 1),
-- --------------------------------------------------------
--
-- Table structure for table `tbl_food`
--
CREATE TABLE IF NOT EXISTS `tbl_food` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`food_type` varchar(50) NOT NULL,
`food_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
You have a comma at the end of INSERT statement, instead of semicolon.

#1064 - You have an error in your SQL syntax; Timestamp table

I've searched the page for answers, however, I am not able to solve this.
I receive the following 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 5
When I am pasting this in the database:
CREATE TABLE IF NOT EXISTS `Votes_History` (
ID int(11) NOT NULL AUTO_INCREMENT,
Username varchar(100) NOT NULL,
Coin varchar(30) NOT NULL,
Timestamp int(11) NOT NULL,
PRIMARY KEY (ID)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6;
This is what I used to enter data into the Votes_History table:
INSERT INTO `Votes_History` (`ID`, `Username`, `Coin`, `Timestamp`)
VALUES
What am I doing wrong here?
Robin
If the query you are using is the same as the one in this sqlfiddle : http://sqlfiddle.com/#!9/01dcb/1 then you query is valid
What I remarked is you are declaring Timestamp as int(11), if you give to your INSERT statement Timestamp value as NOW() or DATE() then its a syntax error.
For TIMESTAMP type example:
# This table used TIMESTAMP type
CREATE TABLE IF NOT EXISTS `Votes_History_Timestamp` (
ID int(11) NOT NULL AUTO_INCREMENT,
Username varchar(100) NOT NULL,
Coin varchar(30) NOT NULL,
Timestamp TIMESTAMP NOT NULL,
PRIMARY KEY (ID)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6;
INSERT INTO `Votes_History_Timestamp` (`Username`, `Coin`, `Timestamp`)
VALUES ('Hamza', '50MAD', NOW());
SQLFiddle link for timestamp : http://sqlfiddle.com/#!9/7878c9/1

You have an error in your SQL syntax when adding query to the mysql database

I am trying to add an addon to my game here, and i need to add this query to the mysql, query is below:
CREATE TABLE `streets` (
`id` int(11) NOT NULL auto_increment,
`min_level` int(11) NOT NULL,
`text` longtext NOT NULL,
`query` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MYISAM ;
INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES ('NULL', 'steps_daily', '100')
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
When i try to enter the query into sql i get this error:
Error
SQL query:
INSERT INTO `settings` ( `conf_id` , `conf_name` , `conf_value` )
VALUES (
'NULL', 'steps_daily', '100'
)
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
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 'ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL' at line 3
You forgot a ; after your INSERT INTO query.
CREATE TABLE `streets` (
`id` int(11) NOT NULL auto_increment,
`min_level` int(11) NOT NULL,
`text` longtext NOT NULL,
`query` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MYISAM ;
INSERT INTO `settings` (`conf_id`, `conf_name`, `conf_value`) VALUES
(NULL, 'steps_daily', '100');
ALTER TABLE `users` ADD `steps` INT( 11 ) NOT NULL ;
P.S.: NULL should not be in quotes. You want the value NULL, not the literall string ,'NULL'.
Do not use quotes for NULL and then try.
INSERT INTO `settings` ( `conf_id` , `conf_name` , `conf_value` )
VALUES (NULL, 'steps_daily', '100');

Why this query throwing error while inserting record

i have created one table using following query
CREATE TABLE `events` (
`event_id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`event_name` varchar(100) NOT NULL,
`description` text,
`event_date` datetime NOT NULL,
`repeat` tinyint(4) NOT NULL,
`share` varchar(100) DEFAULT NULL,
`share_type` varchar(50) NOT NULL,
PRIMARY KEY (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
and now i am trying to insert record using this query
INSERT INTO events (username,event_name,description,event_date,repeat,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');
error i am getting
#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 'username,event_name,description,event_date,repeat,share,share_type) VALUES ('bha' at line 1
repeat is a reserved keyword
use `repeat` in the insert statement
INSERT INTO events (username,event_name,description,event_date,`repeat`,share,share_type) VALUES ('bhavik','Will go home','','2012-11-11 18:10','0','','public');