Syntax error creating table - mysql

When i try to create table using the below code,
CREATE TABLE `audit` (
`audit_id` int(10) unsigned NOT NULL auto_increment,
`order_id` int(11) NOT NULL default '0',
`datestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`message` text NOT NULL,
`message_number` int(11) NOT NULL default '0',
PRIMARY KEY (`audit_id`)
) TYPE=MyISAM AUTO_INCREMENT=196 ;
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 AUTO_INCREMENT=8'
Can someone help me to rectify the error?
Thanks

yes... use ENGINE instead TYPE like this
CREATE TABLE `category` (
`category_id` int(10) unsigned NOT NULL auto_increment,
`department_id` int(10) unsigned NOT NULL default '0',
`name` varchar(50) NOT NULL default '',
`description` varchar(200) default NULL,
PRIMARY KEY (`category_id`)
) ENGINE=MyISAM

Related

MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version

I'm trying to import a SQL file into the database but facing this error. Please help if anyone can solve this error.
SQL query:
CREATE TABLE IF NOT EXISTS `products` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`details` json NOT NULL,
`expiration_date` date ,
`barcode` varchar(125) COLLATE utf8mb4_unicode_ci,
`name` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
`bundle_id` bigint(20) UNSIGNED NOT NULL,
`shelf_id` bigint(20) UNSIGNED DEFAULT NULL,
`delivery_request_id` bigint(20) UNSIGNED DEFAULT NULL,
`status` int(11) NOT NULL DEFAULT '0',
`quantity` int(11) NOT NULL DEFAULT '1',
`weight` int(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
KEY `products_bundle_id_foreign` (`bundle_id`),
KEY `products_shelf_id_foreign` (`shelf_id`),
KEY `products_delivery_request_id_foreign` (`delivery_request_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
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 'json NOT NULL,
`expiration_date` date ,
`barcode` varchar(125) COLLATE utf8m' at line 5

Problems with sql MariaDB (1064)

I can't solve this error showing on my database:
check the manual that corresponds to your MariaDB server version for
the right syntax to use near 'CREATE TABLE tf_links' at line 12
My SQL file code is:
CREATE TABLE tf_cookies (
cid int(10) NOT NULL auto_increment,
uid int(10) NOT NULL default '0',
host VARCHAR(255) default NULL,
data VARCHAR(255) default NULL,
PRIMARY KEY (cid)
) ENGINE=MyISAM;
--
-- tf_links
--
CREATE TABLE tf_links (
lid int(10) NOT NULL auto_increment,
url VARCHAR(255) NOT NULL default '',
sitename VARCHAR(255) NOT NULL default 'Old Link',
sort_order TINYINT(3) UNSIGNED default '0',
PRIMARY KEY (lid)
) ENGINE=MyISAM;

ERROR #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax [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 3 years ago.
I want to create a table in a database with SQL but a 1064 error appears. Can you help me solve my problem.
CREATE TABLE keys (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`key` varchar(40) NOT NULL,
`level` int(2) NOT NULL,
`ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
`is_private_key` tinyint(1) NOT NULL DEFAULT '0',
`ip_addresses` text,
`date_created` int(11) NOT NULL
)
key and keys are keywords in mysql. You can solve the problem by changing them.
CREATE TABLE mykeys (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`key_value` varchar(40) NOT NULL,
`level` int(2) NOT NULL,
`ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
`is_private_key` tinyint(1) NOT NULL DEFAULT '0',
`ip_addresses` text,
`date_created` int(11) NOT NULL
)

#1064 - You have an error in your SQL syntax '(14) NOT NULL, `ID_MEMBER` mediumint(8) unsigned NOT NULL default '0', `ip` ' at line 3

Im getting this 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 '(14) NOT NULL,
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0', `ip` ' at line 3
When I run this script:
CREATE TABLE IF NOT EXISTS `MVElog_online` (
`session` varchar(32) NOT NULL default '0',
`logTime` timestamp(14) NOT NULL,
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
`ip` int(10) unsigned NOT NULL default '0',
`url` text NOT NULL,
PRIMARY KEY (`session`),
KEY `logTime` (`logTime`),
KEY `ID_MEMBER` (`ID_MEMBER`)
) ENGINE=MyISAM;
What does the error mean and what am I doing wrong?
timestamp should not have length, (It's timestamp not timestamp(14))
CREATE TABLE IF NOT EXISTS `MVElog_online` (
`session` varchar(32) NOT NULL default '0',
`logTime` timestamp NOT NULL, -- HERE
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
`ip` int(10) unsigned NOT NULL default '0',
`url` text NOT NULL,
PRIMARY KEY (`session`),
KEY `logTime` (`logTime`),
KEY `ID_MEMBER` (`ID_MEMBER`)
) ENGINE=MyISAM;

sql error code table

CREATE TABLE IF NOT EXISTS `users` ( 
`id` int(11) NOT NULL auto_increment, 
`username` varchar(32) NOT NULL, 
`password` varchar(32) NOT NULL, 
`online` int(20) NOT NULL default '0′, 
`email` varchar(100) NOT NULL, 
`active` int(1) NOT NULL default '0′, 
`rtime` int(20) NOT NULL default '0′, 
PRIMARY KEY (`id`) 
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
This is the original phpmyadmin error message, when I enter the code shown above sql to create the table:
#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
'`password` varchar (32) NULL, `On-line` int NOT (20) NULL default '0 ', NON '
at line 4
I would like to understand how this code should be written correctly and what is wrong!
You should remove strange '0′ quotes for int default values. This should work for you:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(32) NOT NULL,
`password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default 0,
`email` varchar(100) NOT NULL,
`active` int(1) NOT NULL default 0,
`rtime` int(20) NOT NULL default 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
The problem is that you are not closing you quotes correctly. You have '0′ instead of '0'.
You can either fix them of get rid of the quotes at all, since the columns are defined as integer.