Mysql Large SQL query, snipped at 2,000 characters - mysql

With the HeidiSQL db client, I am getting a large SQL query (4.0 KB), snipped at 2,000 characters error. Anyone know why this is the case and what i would need to change on the below table
Please let me know which sections of the code would need updating
-- -----------------------------------------------------
-- Table `warrington_central`.`business`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `warrington_central`.`business` (
`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT ,
`user_id` BIGINT(20) UNSIGNED NOT NULL ,
`alias_title` VARCHAR(255) NOT NULL ,
`primary_category` SMALLINT(5) UNSIGNED NOT NULL ,
`secondary_category` SMALLINT(5) UNSIGNED NOT NULL ,
`tertiary_category` SMALLINT(5) UNSIGNED NULL ,
`title` VARCHAR(255) NOT NULL ,
`premisis_name` VARCHAR(50) NOT NULL ,
`address_id` BIGINT(20) UNSIGNED NOT NULL ,
`geolocation_id` BIGINT(20) UNSIGNED NULL ,
`logo_path` VARCHAR(100) NOT NULL ,
`telephone_number` VARCHAR(25) NOT NULL ,
`mobile` VARCHAR(25) NOT NULL ,
`fax_no` VARCHAR(25) NOT NULL ,
`website` VARCHAR(100) NOT NULL ,
`email` VARCHAR(60) NOT NULL ,
`opening_times` VARCHAR(5000) NOT NULL ,
`history_experience` VARCHAR(5000) NOT NULL ,
`description` TEXT NOT NULL ,
`no_of_employees` MEDIUMINT(8) UNSIGNED NOT NULL ,
`date_establised` DATE NULL ,
`show_google_map` ENUM('0','1') NOT NULL ,
`show_street_view` ENUM('0','1') NOT NULL ,
`show_comment` ENUM('0','1') NOT NULL ,
`add_contact_form` ENUM('0','1') NOT NULL ,
`viewable_to_members_only` ENUM('0','1') NOT NULL ,
`link_to_user_profile` ENUM('0','1') NOT NULL ,
`admin_package_id` TINYINT(1) UNSIGNED NOT NULL ,
`package_start_date` DATETIME NOT NULL ,
`package_end_date` DATETIME NULL ,
`package_comment` VARCHAR(500) NOT NULL ,
`created_on` DATETIME NOT NULL ,
`updated_by` BIGINT(20) UNSIGNED NOT NULL ,
`updated_on` DATETIME NOT NULL ,
`approved` ENUM('Inprocess','Yes','No') NOT NULL DEFAULT 'Inprocess' ,
`visible` ENUM('0','1') NOT NULL DEFAULT '0' ,
`hits` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 ,
`advertise_to` DATETIME NULL ,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `alias_title` (`alias_title` ASC/* large SQL query (4.0 KB), snipped at 2,000 characters */
SHOW WARNINGS;

Well, you can also just go to Tools > Preferences > Logging, and set the "lines in SQL log" setting to another value.
But as #doublesharp said, that's just a cosmetic thing. The query sent to the server is certainly not cut.

This seems to be a function of HeidiSQL and does not actually affect your query running. If it were generating errors or warnings, you would see them after the comment about your query being snipped at 2,000 characters.
See the source code here: http://code.google.com/p/heidisql/source/browse/trunk/source/main.pas?r=4127
prefLogSqlWidth := GetRegValue(REGNAME_LOGSQLWIDTH, DEFAULT_LOGSQLWIDTH);
Then the message is generate with this code
// Shorten very long messages
Len := Length(Msg);
snip := (prefLogSqlWidth > 0) and (Len > prefLogSqlWidth);
IsSQL := Category in [lcSQL, lcUserFiredSQL]; if snip then begin
Msg :=
Copy(Msg, 0, prefLogSqlWidth) +
'/* large SQL query ('+FormatByteNumber(Len)+'), snipped at ' +
FormatNumber(prefLogSqlWidth) +
' characters */';
end else if (not snip) and IsSQL then
Msg := Msg + Delimiter;
if not IsSQL then
Msg := '/* ' + Msg + ' */';
Seems like you can change this value in the registry (http://code.google.com/p/heidisql/source/browse/trunk/source/const.inc?r=4133)
REGNAME_LOGSQLWIDTH = 'logsqlwidth';
DEFAULT_LOGSQLWIDTH = 2000;
The key is probably located here HKEY_CURRENT_USER\Software\HeidiSQL\Servers

Related

How to resolve an error near NULL when creating a table

Whenever I try to create a table
CREATE TABLE registration` (`id` INT NOT NULL , `name` VARCHAR(30) NOT NULL , `email` VARCHAR(20) NOT NULL , `password` VARCHAR(15) NOT NULL , `DOB` DATE NOT NULL , `age` INT NOT NULL , `number` BIGINT NOT NULL , `religion` VARCHAR(10) NOT NULL , `education` VARCHAR(20) NOT NULL , `profession` VARCHAR(20) NOT NULL , `gender` ENUM NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
The following error occurs
#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 'NOT NULL , PRIMARY KEY (id)) ENGINE = InnoDB' at line 1
ENUM needs values so you need to define the values they can get
CREATE TABLE registration (
`id` INT NOT NULL
, `name` VARCHAR(30) NOT NULL
, `email` VARCHAR(20) NOT NULL
, `password` VARCHAR(15) NOT NULL
, `DOB` DATE NOT NULL
, `age` INT NOT NULL
, `number` BIGINT NOT NULL
, `religion` VARCHAR(10) NOT NULL
, `education` VARCHAR(20) NOT NULL
, `profession` VARCHAR(20) NOT NULL
, `gender` ENUM ('male','female')
, PRIMARY KEY (`id`)
) ENGINE = InnoDB;
When you declare a ENUM column (your gender column) you have to assign all possible values for the enumeration (See here for syntax)

MySQL error while trying to create table,

I'm using PHPMyAdmin, hosted with hostgator, to add a table to a database, but I keep getting 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 ') NOT NULL , note TEXT NOT NULL , cardNumber BIGINT(20) NOT NULL , `nameC' at line 1
Here's what I have:
and here's the preview of the SQL
CREATE TABLE `nightwin_mark-inn`.`guests` (
`id` INT(3) NOT NULL AUTO_INCREMENT ,
`dateIn` DATE NOT NULL ,
`dateOut` DATE NOT NULL ,
`email` TEXT NOT NULL ,
`phone` INT(10) NOT NULL ,
`room` TINYINT(2) NOT NULL ,
`price` DOUBLE(6) NOT NULL ,
`note` TEXT NOT NULL ,
`cardNumber` BIGINT(20) NOT NULL ,
`nameCard` TEXT NOT NULL ,
`expDate` TEXT NOT NULL ,
`cvc` TINYINT(3) NOT NULL ,
PRIMARY KEY (`id`)
)
What's causing this issue? Do I have the length of one of the fields wrong?
Try to use this
price` DOUBLE(6,2) NOT NULL //9999.99 max value stored
instead of
price` DOUBLE(6) NOT NULL
Note: for price field use datatype DECIMAL more preferable. In FLOAT or DOUBLE datatype you will get rounding number issue
Reference
You can try below - DOUBLE(6) should be only DOUBLE
CREATE TABLE `nightwin_mark-inn`.`guests` ( `id` INT(3) NOT NULL AUTO_INCREMENT ,
`dateIn` DATE NOT NULL , `dateOut` DATE NOT NULL , `email` TEXT NOT NULL ,
`phone` INT(10) NOT NULL , `room` TINYINT(2) NOT NULL , `price` DOUBLE NOT NULL ,
`note` TEXT NOT NULL , `cardNumber` BIGINT(20) NOT NULL , `nameCard` TEXT NOT NULL ,
`expDate` TEXT NOT NULL , `cvc` TINYINT(3) NOT NULL , PRIMARY KEY (`id`))
please try using this MySQL statement
CREATE TABLE `guests` ( `id` INT(3) NOT NULL AUTO_INCREMENT , `dateIn` DATE NOT NULL , `dateOut` DATE NOT NULL , `email` TEXT NOT NULL , `phone` INT(10) NOT NULL , `room` TINYINT(2) NOT NULL , `price` DOUBLE(6,2) NOT NULL , `note` TEXT NOT NULL , `cardNumber` BIGINT(20) NOT NULL , `nameCard` TEXT NOT NULL , `expDate` TEXT NOT NULL , `cvc` TINYINT(3) NOT NULL , PRIMARY KEY (`id`));
please try using this MySQL statement
CREATE TABLE guests ( id INT(3) NOT NULL AUTO_INCREMENT , dateIn DATE NOT NULL , dateOut DATE NOT NULL , email TEXT NOT NULL , phone INT(10) NOT NULL , room TINYINT(2) NOT NULL , price DOUBLE(6,2) NOT NULL , note TEXT NOT NULL , cardNumber BIGINT(20) NOT NULL , nameCard TEXT NOT NULL , expDate TEXT NOT NULL , cvc TINYINT(3) NOT NULL , PRIMARY KEY (id));

Having an error in sql while creating table

I am trying to create a table on my database. this is the error
#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 ') NOT NULL , `ctc` DOUBLE(5) NOT NULL , `ref` VARCHAR(50) NOT NULL , `date` D' at line 1
My query:
CREATE TABLE `job`.`form_details` (
`email_id` VARCHAR(50) NOT NULL ,
`name` VARCHAR(50) NOT NULL ,
`number` VARCHAR(14) NOT NULL ,
`city` VARCHAR(50) NOT NULL ,
`skill` VARCHAR(50) NOT NULL ,
`qualification` VARCHAR(50) NOT NULL ,
`position` VARCHAR(50) NOT NULL ,
`exp` DOUBLE(5) NOT NULL ,
`ctc` DOUBLE(5) NOT NULL ,
`ref` VARCHAR(50) NOT NULL ,
`date` DATE NOT NULL ,
`time stamp` TIMESTAMP(30) NOT NULL ) ENGINE = InnoDB;
A double's precision is specified by two arguments - (M, D) - M digits in total and D digits after the decimal point. A timestamp's precision must be no greater than 6. So:
CREATE TABLE `job`.`form_details` (
`email_id` VARCHAR(50) NOT NULL ,
`name` VARCHAR(50) NOT NULL ,
`number` VARCHAR(14) NOT NULL ,
`city` VARCHAR(50) NOT NULL ,
`skill` VARCHAR(50) NOT NULL ,
`qualification` VARCHAR(50) NOT NULL ,
`position` VARCHAR(50) NOT NULL ,
`exp` DOUBLE(5, 2) NOT NULL , -- Two arguments for the double's precision
`ctc` DOUBLE(5, 2) NOT NULL , -- Here too
`ref` VARCHAR(50) NOT NULL ,
`date` DATE NOT NULL ,
`time stamp` TIMESTAMP(6) NOT NULL -- Timestamp precision capped at 6
) ENGINE = InnoDB

What does the engine and char set means after the ()?

DROP DATABASE IF EXISTS `Database` ;
CREATE DATABASE `Database` ;
DROP TABLE IF EXISTS `Registration Form` ;
CREATE TABLE `Registration Form`
(
`ID` int(11) NOT NULL AUTO_INCREMENT ,
`Username` varchar(50) NOT NULL ,
`Password` varchar(50) NOT NULL ,
`Display Name` varchar(255) NOT NULL ,
`Question` varchar(255) NOT NULL ,
`Answer` varchar(255) NOT NULL ,
`Title` varchar(10) NOT NULL ,
`Name` varchar(255) NOT NULL ,
`Date Of Birth` date NOT NULL ,
`Gender` varchar(10) NOT NULL ,
`Address` varchar(255) NOT NULL ,
`Postal Code` int(11) NOT NULL ,
`City / Town` varchar(255) NOT NULL ,
`Federal Territory / State` varchar(255) NOT NULL ,
`Citizenship` varchar(255) NOT NULL ,
`E-mail` varchar(255) NOT NULL ,
`Contact Number` int(20) NOT NULL ,
`Registration Date` datetime NOT NULL ,
PRIMARY KEY ( `ID` )
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
I'm just starting to work arounnd mysql and php ... so bear with me as im a newbie ...
What does ALL the code after the CREATE() mean ? Why is there a ENGINE and DEFAULT what do they do ? Is CHARSET same as collation , if yes why not put it inside the row instead ? Do you need to give a length/value for date and daetime ?
CREATE TABLE is the sql clause which is required to creating a table.
After that you have to give a table name i.e "Registration Form" .but avoid spaces in between table name
Next what ever you gave those are column name along with their datatype and size.NOT NULL means while inserting data those column can't be blank.
For more details check the below link
http://www.tutorialspoint.com/mysql/mysql-create-tables.htm

The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs

I am getting the below message on a table I am trying to create.
The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
Anyone know the answer to this please?
-- Table `warrington_central`.`job`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `warrington_central`.`job` (
`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT ,
`alias_title` VARCHAR(255) NOT NULL ,
`reference_number` VARCHAR(100) NOT NULL ,
`title` VARCHAR(255) NOT NULL ,
`primary_category` SMALLINT(5) UNSIGNED NOT NULL ,
`secondary_category` SMALLINT(5) UNSIGNED NOT NULL ,
`tertiary_category` SMALLINT(5) UNSIGNED NULL ,
`address_id` BIGINT(20) UNSIGNED NOT NULL ,
`geolocation_id` BIGINT(20) UNSIGNED NULL ,
`company` VARCHAR(255) NOT NULL ,
`description` VARCHAR(10000) NOT NULL ,
`skills_required` VARCHAR(10000) NOT NULL ,
`job_type` TINYINT(2) UNSIGNED NOT NULL ,
`experience_months_required` TINYINT(2) UNSIGNED NOT NULL ,
`experience_years_required` TINYINT(2) UNSIGNED NOT NULL ,
`salary_range` VARCHAR(30) NOT NULL ,
`extra_benefits_above_salary` VARCHAR(500) NOT NULL ,
`available_from` DATE NULL ,
`available_to` DATE NULL ,
`extra_location_details` VARCHAR(1000) NOT NULL ,
`contact_email` VARCHAR(100) NOT NULL ,
`contact_phone_number` VARCHAR(20) NOT NULL ,
`contact_mobile_number` VARCHAR(20) NOT NULL ,
`terms_conditions_application` VARCHAR(5000) NOT NULL ,
`link_to_profile` ENUM('0','1') NOT NULL ,
`created_on` DATETIME NOT NULL ,
`updated_on` DATETIME NOT NULL ,
`updated_by` BIGINT(20) UNSIGNED NOT NULL ,
`add_contact_form` ENUM('0','1') NOT NULL ,
`admin_package_id` TINYINT(1) UNSIGNED NOT NULL ,
`package_start_date` DATETIME NOT NULL ,
`package_end_date` DATETIME NULL ,
`package_comment` VARCHAR(500) NOT NULL ,
`viewable_to_members_only` ENUM('0','1') NOT NULL ,
`advertise_to` DATETIME NULL ,
`show_comment` ENUM('0','1') NOT NULL ,
`hits` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 ,
`visible` ENUM('0','1') NOT NULL DEFAULT '0' ,
`approved` ENUM('I/* large SQL query (3.9 KB), snipped at 2,000 characters */
/* SQL Error (1118): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs */
SHOW WARNINGS;
Change description and skills_required to be type text
You are getting that message because the sum of all the fields is > 65k