From documentation, I'm creating pma_history table.
This is the only part of scripts/create_tables.sql that fails:
CREATE TABLE IF NOT EXISTS `pma_history` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`username` varchar(64) NOT NULL default '',
`db` varchar(64) NOT NULL default '',
`table` varchar(64) NOT NULL default '',
`timevalue` timestamp(14) NOT NULL,
`sqlquery` text NOT NULL,
PRIMARY KEY (`id`),
KEY `username` (`username`,`db`,`table`,`timevalue`)
)
ENGINE=MyISAM COMMENT='SQL history for phpMyAdmin'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
This is what server says:
#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, `sqlquery` text NOT NULL, PRIMARY KEY (`id`),
KEY `user' at line 6
Leave the length of the timestamp column
`timevalue` timestamp NOT NULL
Prior to version 4.1, the format in which MySQL retrieves and displays TIMESTAMP values depends on the display size
Taken from here
Related
I'm trying to migrate a db
from: MySQL Distrib 5.5.60-MariaDB, for Linux (x86_64)
to: MySQL 5.5.4, UNIX
I tried importing the db as a zip package and it started throwing errors so now I'm trying to re-create each table one at a time on phpMyAdmin.
The query below is throwing a #1064 Syntax error, and I'm having trouble figuring out the issue.
MySQL Said:
#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 '(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
`st' at line 6
I'm looking at line 6, trying to find any reserved words, missing data, typos, and or obsolete commands but no luck.
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP,
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
I could use some help.
Thanks in advance.
CURRENT_TIMESTAMP is not good
Try this:
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
This works in SQL Fiddle:
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
i.e., remove the precision (the (2)) from the definition of the date_added column.
TIMESTAMP(2) is valid syntax, but not in combination with the DEFAULT CURRENT_TIMESTAMP nor ON UPDATE CURRENT_TIMESTAMP auto-initializers.
ım working localhost, after my work end. I want a upload my db server phpmyadmin. But still syntax error how can ı fix this?
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 '(6) NULL DEFAULT NULL,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO' at line 7 )
DROP TABLE IF EXISTS `veriler`;
CREATE TABLE `veriler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gpa` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`durumu` int(10) NULL DEFAULT NULL,
`miktari` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tarih` datetime(6) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
Support for fractional seconds in DATETIME values wasn't added until version MySQL 5.6. If you can't upgrade your server, you will need to remove the trailing (6) from the definition of column tarih i.e.
`tarih` datetime NULL DEFAULT NULL,
Note that you will lose precision in those values relative to your MariaDB server. If you need to store microseconds in your data values, you will need to upgrade the MySQL server to version 5.6 or later.
Try this simplified version:
CREATE TABLE `veriler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici` varchar(60) DEFAULT NULL,
`gpa` varchar(255) DEFAULT NULL,
`durumu` int(10) DEFAULT NULL,
`miktari` varchar(20) DEFAULT NULL,
`tarih` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
this is my one of database table structure and after insert some fields as row into that i can't update columns and i get error:
CREATE TABLE `channels` (
`id` int(11) NOT NULL,
`channelName` varchar(30) COLLATE utf8_persian_ci NOT NULL,
`channelLink` varchar(50) COLLATE utf8_persian_ci NOT NULL,
`channelDescription` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelImageFileName` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelAvatarFileName` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelState` tinyint(1) NOT NULL,
`channelType` enum('channels','userCreatedChannels') COLLATE utf8_persian_ci NOT NULL,
`channelOwnerUserId` int(11) NOT NULL,
`fileServerUrlId` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `channels`
--
ALTER TABLE `channels`
ADD PRIMARY KEY (`id`);
Error and notice:
This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.
Error
UPDATE `channels` SET `channelState` = '1' WHERE LIMIT 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 'LIMIT 1' at line 1
id of this table is unique and A_I, how can i resolve this problem?
this is my table export:
CREATE TABLE IF NOT EXISTS `order` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`comment` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`shipping_cost` double DEFAULT NULL,
`customer_id` int(11) NOT NULL,
`delivery_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`invoice_nr` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `order_customer_id_index` (`customer_id`),
KEY `order_invoice_nr_index` (`invoice_nr`),
KEY `order_created_at_index` (`created_at`),
KEY `order_updated_at_index` (`updated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
when I run now:
ALTER TABLE order AUTO_INCREMENT=1000;
I get:
#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 'order AUTO_INCREMENT=1000' at line 1
the table is empty!
mysql version: 5.5.44-0ubuntu0.14.04.1
someone has an idea what could cause me this problem?
if I put for example this:
ALTER TABLE asdasdfasdfasdf AUTO_INCREMENT=1000;
I get
1146 - Table 'mydb.asdasdfasdfasdf' doesn't exist
Try:
ALTER TABLE `order` AUTO_INCREMENT=1000;
Order is a reserved word, it's trying to order...
I am getting an error when I try to import data through the command:
mysql -u root -p"root" cvdb < "cvdb.sql"
The error I am getting is:
ERROR 1064 (42000) at line 72: 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,
Created datetime NOT NULL default ' 0000-00-00 00:00:00 ',
' at line 14
The code of my SQL file is:
DROP TABLE IF EXISTS `activity`;
CREATE TABLE `activity` (
`AllDay` enum('YES','NO') default 'NO',
`ActivityID` int(11) unsigned NOT NULL auto_increment,
`Type` int(11) NOT NULL default '0',
`Priority` int(11) NOT NULL default '0',
`Status` int(11) NOT NULL default '0',
`Title` varchar(255) default NULL,
`DueDate` datetime default NULL,
`CompletedDate` datetime default NULL,
`Details` text,
`Creator` int(11) NOT NULL default '0',
`Owner` int(11) default NULL,
`ModifiedBy` int(11) default NULL,
`Modified` timestamp(14) NOT NULL,
`Created` datetime NOT NULL default ' 0000-00-00 00:00:00 ',
`Start` datetime default NULL,
`End` datetime default NULL,
`AttachmentType` enum('NONE','FILE','LINK') NOT NULL default 'NONE',
`Location` varchar(25) default NULL,
`visibility` enum('PRIVATE','PUBLIC') NOT NULL default 'PRIVATE',
`Notes` varchar(255) default NULL,
PRIMARY KEY (`ActivityID`),
UNIQUE KEY `ActivityID` (`ActivityID`),
KEY `Type` (`Type`),
KEY `Priority` (`Priority`),
KEY `Status` (`Status`),
KEY `Creator` (`Creator`),
KEY `Owner` (`Owner`),
KEY `ModifiedBy` (`ModifiedBy`),
KEY `Location` (`Location`)
) ENGINE=InnoDB;
the error is here Modified timestamp(14) NOT NULL. you should remove (14) from timestamp.
your partial DDL,
`ModifiedBy` int(11) default NULL,
`Modified` timestamp NOT NULL,
`Created` datetime NOT NULL default '0000-00-00 00:00:00',
`Start` datetime default NULL,
From mysql doc
Incompatible change: In very old versions of MySQL (prior to 4.1), the
TIMESTAMP data type supported a display width, which was silenty
ignored beginning with MySQL 4.1. This is deprecated in MySQL 5.1, and
removed altogether in MySQL 5.5. These changes in behavior can lead to
two problem scenarios when trying to use TIMESTAMP(N) columns with a
MySQL 5.5 or later server:
...
You should try to handle potential issues of these types proactively
by updating with ALTER TABLE any TIMESTAMP(N) columns in your
databases so that they use TIMESTAMP instead, before performing any
upgrades.
So try to remove the (14)
in
Modified timestamp(14) NOT NULL
or as said in doc, try to make alter table statements on your timestamp columns before import.