Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While importing sql table getting error due to collation

the code for creating table is given below while i try to import this table in new database am getting the following error

Query

CREATE TABLE IF NOT EXISTS `blogs` (
  `blog_id` int(10) NOT NULL AUTO_INCREMENT,
  `blog_title` text NOT NULL,
  `blog_content` text NOT NULL,
  `created_on` datetime(6) NOT NULL,
  `created_by` int(20) NOT NULL,
  `updated_on` datetime(6) NOT NULL,
  `updated_by` int(20) NOT NULL,
  PRIMARY KEY (`blog_id`)
) Engine=InnoDB  AUTO_INCREMENT=14 ;

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 '(6) NOT NULL, created_by int(20) NOT NULL,
updated_on datetime(6) NOT NU' at line 11

kindly guide me to solve this issues still i need to import many tables

like image 951
vimal kumar Avatar asked Aug 02 '16 07:08

vimal kumar


People also ask

What does collation mean in SQL?

A collation specifies the bit patterns that represent each character in a dataset. Collations also determine the rules that sort and compare data. SQL Server supports storing objects that have different collations in a single database.

What does illegal mix of collations mean?

So what is an "illegal mix of collations"? An "illegal mix of collations" occurs when an expression compares two strings of different collations but of equal coercibility and the coercibility rules cannot help to resolve the conflict.

What is DB collation?

Collation refers to a set of rules that determine how data. is sorted and compared. Character data is sorted using rules that define the. correct character sequence, with options for specifying case-sensitivity, accent. marks, kana character types and character width.


1 Answers

Remove length (6) from datetime(6).

So your query would look something like this,

CREATE TABLE IF NOT EXISTS `blogs` (
  `blog_id` int(10) NOT NULL AUTO_INCREMENT,
  `blog_title` text NOT NULL,
  `blog_content` text NOT NULL,
  `created_on` datetime NOT NULL,
  `created_by` int(20) NOT NULL,
  `updated_on` datetime NOT NULL,
  `updated_by` int(20) NOT NULL,
  PRIMARY KEY (`blog_id`)
) Engine=InnoDB  AUTO_INCREMENT=14 ;
like image 139
Alok Patel Avatar answered Sep 30 '22 15:09

Alok Patel