MySQL Error 1366 Incorrect String Value - mysql

I have been looking everywhere for an answer, but I still have not found a solution.
Background:
I have a MySQL Server 5.5 running on my computer for testing data that will be eventually loaded into a Production Server for my company. I created the database in MySQL Workbench and have edited it where appropriate to fit my data as I loaded it. My data is nowhere near clean, so for the most part I am using VARCHAR for my fields, since a whole bunch of random things can be put into the field. I have tried changing multiple things and I am no longer sure whether anything I have done has fixed or even helped to eliminate the issue at all.
My Code:
DB Creation:
SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
SET NAMES utf8;
DROP SCHEMA IF EXISTS `mydb` ;
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Customer_Account`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Customer_Account` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Customer_Account` (
`idCustomer_Account` VARCHAR(20) NOT NULL,
`Name` VARCHAR(130) NOT NULL,
`Billing_Street` VARCHAR(150) NULL,
`Billing_City` VARCHAR(30) NULL,
`Billing_StateProvince` VARCHAR(25) NULL,
`Billing_PostalCode` VARCHAR(15) NULL,
`Billing_Country` VARCHAR(20) NULL,
`Location_Type` VARCHAR(15) NULL,
`Parent_ID` VARCHAR(20) NULL,
`Parent_Name` VARCHAR(130) NULL,
PRIMARY KEY (`idCustomer_Account`),
UNIQUE INDEX `idCustomer_Account_UNIQUE` (`idCustomer_Account` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
'CONSTRAINT `Parent_ID`
FOREIGN KEY (`idCustomer_Account`)
REFERENCES `mydb`.`Customer_Account` (`idCustomer_Account`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)'
-- -----------------------------------------------------
-- Table `mydb`.`Customer_Address`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Customer_Address` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Customer_Address` (
`idCustomer_Address` VARCHAR(20) NOT NULL,
`Name` VARCHAR(50) NOT NULL,
`Name_Int` INT,
`Address` VARCHAR(80) NULL,
`City` VARCHAR(30) NULL,
`State` VARCHAR(5) NULL,
`ZIP` VARCHAR(15) NULL,
`LinkedAccount_Name` VARCHAR(100) NULL,
`LinkedAccount_ID` VARCHAR(20) NULL,
`CADD` INT,
PRIMARY KEY (`idCustomer_Address`),
UNIQUE INDEX `idCustomer_Address_UNIQUE` (`idCustomer_Address` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `mydb`.`Contacts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Contacts` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Contacts` (
`idContacts` VARCHAR(20) NOT NULL,
`Name` VARCHAR(50) NOT NULL,
`Title` VARCHAR(130) NULL,
`Mailing_Street` VARCHAR(110) NULL,
`Mailing_City` VARCHAR(30) NULL,
`Mailing_State` VARCHAR(25) NULL,
`Mailing_PostalCode` VARCHAR(20) NULL,
`Phone` VARCHAR(50) NULL,
`Account_ID` VARCHAR(20) NULL,
`Account_Name` VARCHAR(100) NULL,
PRIMARY KEY (`idContacts`),
UNIQUE INDEX `idContacts_UNIQUE` (`idContacts` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
-- -----------------------------------------------------
-- Table `mydb`.`Contact_Details`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Contact_Details` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Contact_Details` (
`idContact_Details` VARCHAR(20) NOT NULL,
`Salutation` VARCHAR(70) NULL,
`First_Name` VARCHAR(30) NULL,
`Last_Name` VARCHAR(50) NULL,
`Title` VARCHAR(130) NULL,
`Mailing_Street` VARCHAR(175) NULL,
`Mailing_City` VARCHAR(50) NULL,
`Mailing_StateProvince` VARCHAR(30) NULL,
`Mailing_PostalCode` VARCHAR(20) NULL,
`Mailing_Country` VARCHAR(25) NULL,
`Phone` VARCHAR(50) NULL,
`Mobile` VARCHAR(35) NULL,
`Fax` VARCHAR(45) NULL,
`Email` VARCHAR(75) NULL,
`Email_OptOut` VARCHAR(1) NULL,
`Account_Owner` VARCHAR(20) NULL,
`Account_Name` VARCHAR(125) NULL,
`Account_ID` VARCHAR(20) NOT NULL,
`Active` VARCHAR(2) NOT NULL,
PRIMARY KEY (`idContact_Details`),
UNIQUE INDEX `idContact_Details_UNIQUE` (`idContact_Details` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
'INDEX `Account_ID_idx` (`Account_ID` ASC)'
-- -----------------------------------------------------
-- Table `mydb`.`WF1_SR_Accounts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`WF1_SR_Accounts` ;
CREATE TABLE IF NOT EXISTS `mydb`.`WF1_SR_Accounts` (
`idWF1_SR_Accounts` VARCHAR(20) NOT NULL,
`Name` VARCHAR(125) NOT NULL,
`Billing_Street` VARCHAR(135) NULL,
`Billing_City` VARCHAR(50) NULL,
`Billing_State` VARCHAR(20) NULL,
`Billing_PostalCode` VARCHAR(20) NULL,
`Billing_Country` VARCHAR(25) NULL,
`Location_Type` VARCHAR(20) NULL,
`Parent_ID` VARCHAR(20) NULL,
`Parent_Name` VARCHAR(125) NULL,
`SR_Account?` VARCHAR(5) NULL,
`WF1_Account?` VARCHAR(5) NULL,
`WF1_AccountNum` VARCHAR(10) NULL,
`WF1_AccountStatus` VARCHAR(25) NULL,
`WF1_AccountCreated` VARCHAR(50) NULL,
`WF1_BU` VARCHAR(10) NULL,
`WF1_Collector` VARCHAR(20) NULL,
`WF1_CreditHold` VARCHAR(5) NULL,
`WF1_CreditLimit` VARCHAR(10) NULL,
`WF1_CreditRating` VARCHAR(15) NULL,
`WF1_DVP` VARCHAR(20) NULL,
`WF1_PaymentTerms` VARCHAR(20) NULL,
`WF1_RSD` VARCHAR(40) NULL,
`WF1_TerritoryName` VARCHAR(45) NULL,
`WF1_TerritoryNumber` VARCHAR(5) NULL,
`Select_` VARCHAR(5) NULL,
`New_Select` VARCHAR(5) NULL,
`CRMFusion_Use` VARCHAR(10) NULL,
`CRMFusion_Change` VARCHAR(10) NULL,
PRIMARY KEY (`idWF1_SR_Accounts`),
UNIQUE INDEX `idWF1_SR_Accounts_UNIQUE` (`idWF1_SR_Accounts` ASC))
ENGINE = InnoDB DEFAULT CHARSET=utf8;
SET SQL_MODE=#OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=#OLD_UNIQUE_CHECKS;
Note: I have also substituted latin1 for utf8 in SET NAMES, DEFUALT CHARSET, and CHARACTER_SET_SERVER, and tried to make my .txt files of both encryption types.
I also ran
SHOW VARIABLES like 'char%';
and this is my result:
Variable_name Value
character_set_client latin1
character_set_connection latin1
character_set_database utf8
character_set_filesystem binary
character_set_results latin1
character_set_server latin1
character_set_system utf8
character_sets_dir C:\Program Files\MySQL\MySQL Server 5.5\share\charsets\
Note: at one point, everything but filesystem and server were utf8 and it did not work either.
I have also changed the encryption type in excel and notepad++ and changing that did not seem to help.

The primary Key need to be changed from INT to VARCHAR(45) data types.

Related

MySQL ALTER TABLE increase column varchar size - 0 row(s) affected?

I am trying to test out MySQL alter table to increase varchar column size.
VARCHAR(50) -> VARCHAR(100)
I try to execute command -> ALTER TABLE profile CHANGE COLUMN username username VARCHAR(100) DEFAULT NULL;
MySQL response complete with 0 row(s) affected. How is that possible?
Shouldn't increase varchar size will impact all rows within the table?
I hope to know why MySQL can process this alter table command so fast.
Below is my table script, there are total of 9209 rows.
CREATE TABLE `mytable` (
`userprofileseqid` VARCHAR(50) NOT NULL,
`clientdeviceseqid` VARCHAR(50) NOT NULL,
`userid` VARCHAR(50) NOT NULL,
`username` VARCHAR(100) DEFAULT NULL,
`usermobileno` VARCHAR(30) DEFAULT NULL,
`userstatus` VARCHAR(11) DEFAULT NULL,
`type` VARCHAR(30) DEFAULT NULL,
`role` VARCHAR(30) DEFAULT NULL,
`buscode` VARCHAR(50) DEFAULT NULL,
`distname` VARCHAR(100) DEFAULT NULL,
`distcode` VARCHAR(30) DEFAULT NULL,
`hqmobileno` VARCHAR(50) DEFAULT NULL,
`otpsubmissionblocked` INT(11) DEFAULT NULL,
`channel` VARCHAR(11) DEFAULT NULL,
`createddate` DATETIME NOT NULL,
`dealerstatus` VARCHAR(11) DEFAULT NULL,
`dealername` VARCHAR(100) DEFAULT NULL,
`email` VARCHAR(50) DEFAULT NULL,
`userfullname` VARCHAR(200) DEFAULT '',
PRIMARY KEY (`userprofileseqid`),
UNIQUE KEY `userprofile_unique_index` (`clientdeviceseqid`,`userid`,`usermobileno`)
) ENGINE=INNODB DEFAULT CHARSET=latin1
I try on both MySQL version 5.7.20 & 8.0.28, both return 0 row(s) affected.
However, when downgrade the varchar size VARCHAR(100) -> VARCHAR(50), it will show 9209 row(s) affected without issue.

mysql table with gibberish values

I have the following sql file to create Table:
CREATE TABLE `patient_namer` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`id_number` varchar(45) NOT NULL,
`first_name` varchar(45) NOT NULL,
`last_name` varchar(45) NOT NULL,
`father_name` varchar(45) NOT NULL,
`department` varchar(45) NOT NULL,
`case_number` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `patient_namer` (`id_number`,`first_name`,`last_name`,`father_name`,`department`,`case_number`) VALUES
('205436340','טל', 'גדכדגדככדג', 'גדכגדכג', 'wowDep', '43625');
However, when I inspect the data in workbench I get the following in first_name column for example: ����. Why is that? As far as I know utf8mb4_unicode_ci Collation should satisfy hebrew charset...

mysql workbench No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar

I'm learn sql for web design. I am using MySql WorkBench, as stated in the title I'm wondering if there something in sql code is missing.
Given error: 14:59:45 CREATE TABLE branch ( branch_id int(11) NOT NULL, branch_name varchar(45) NOT NULL, branch_phone varchar(45) NOT NULL, branch_email varchar(45) NOT NULL, branch_address varchar(100) NOT NULL, branch_gst_registration varchar(45) NOT NULL, branch_fax varchar(45) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar. 0.000 sec
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `info263_19s2_wheel_alignment`
--
-- --------------------------------------------------------
--
-- Table structure for table `branch`
--
CREATE TABLE `branch` (
`branch_id` int(11) NOT NULL,
`branch_name` varchar(45) NOT NULL,
`branch_phone` varchar(45) NOT NULL,
`branch_email` varchar(45) NOT NULL,
`branch_address` varchar(100) NOT NULL,
`branch_gst_registration` varchar(45) NOT NULL,
`branch_fax` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `branch`
--
INSERT INTO `branch` (`branch_id`, `branch_name`, `branch_phone`, `branch_email`, `branch_address`, `branch_gst_registration`, `branch_fax`) VALUES
(1, 'Ilam', '03-3745034', 'ilam#tyretown.net.nz', '25 Ilam Road, Ilam, Christchurch, 8023 ', '90881914', '0212648888'),
(2, 'Riccarton', '03-3457675', 'riccarton#tyretown.net.nz', '312 Blenheim Road, Riccarton, Christchurch 8011', '90874514', '0214874512'),
(3, 'Cashmere', '03-3323521', 'cashmere#tyretown.2go.net.nz', '17 Centarus Road, Cashmere, Christchurch 8023', '89422154', '0278941544'),
(4, 'Kaipoi', '03-3277140', 'kaipoi#tyretown.net.nz', '49 Williams Street, Kaipoi, Canterbury, 8421', '98715014', '0241510154'),
(5, 'Linwood', '03-3745035', 'linwood#tyretown.net.nz', '175 Linwood Avenue, Linwood, Christchurch, 8624', '97154714', '0275488541'),
(6, 'Burnside', '03-3599009', 'burnside#tyretown.net.nz', '14 Wairakei Road, Burnside, Christchurch, 8422', '93121544', '0215844842'),
(7, 'Rangiora', '03-3277140', 'rangiora#tyretown.net.nz', '482 Lineside Road, Rangiora, Rangiora, 9014', '78465141', '0204154124');
-- --------------------------------------------------------
--
-- Table structure for table `inspection`
--
CREATE TABLE `inspection` (
`inspection_id` varchar(7) NOT NULL,
`rear_axle_camber_left_before` varchar(45) NOT NULL,
`rear_axle_camber_right_before` varchar(45) NOT NULL,
`rear_axle_camber_cross_before` varchar(45) NOT NULL,
`rear_axle_camber_left_actual` varchar(45) NOT NULL,
`rear_axle_camber_right_actual` varchar(45) NOT NULL,
`rear_axle_camber_cross_actual` varchar(45) NOT NULL,
`rear_axle_toe_left_before` varchar(45) NOT NULL,
`rear_axle_toe_right_before` varchar(45) NOT NULL,
`rear_axle_toe_total_before` varchar(45) NOT NULL,
`rear_axle_toe_left_actual` varchar(45) NOT NULL,
`rear_axle_toe_right_actual` varchar(45) NOT NULL,
`rear_axle_toe_total_actual` varchar(45) NOT NULL,
`rear_axle_geometrical_driving_axis_before` varchar(45) NOT NULL,
`rear_axle_geometrical_driving_axis_actual` varchar(45) NOT NULL,
`front_axle_camber_left_before` varchar(45) NOT NULL,
`front_axle_camber_right_before` varchar(45) NOT NULL,
`front_axle_camber_cross_before` varchar(45) NOT NULL,
`front_axle_camber_left_actual` varchar(45) NOT NULL,
`front_axle_camber_right_actual` varchar(45) NOT NULL,
`front_axle_camber_cross_actual` varchar(45) NOT NULL,
`front_axle_caster_left_before` varchar(45) NOT NULL,
`front_axle_caster_right_before` varchar(45) NOT NULL,
`front_axle_caster_cross_before` varchar(45) NOT NULL,
`front_axle_caster_left_actual` varchar(45) NOT NULL,
`front_axle_caster_right_actual` varchar(45) NOT NULL,
`front_axle_caster_cross_actual` varchar(45) NOT NULL,
`front_axle_SAI_left_before` varchar(45) NOT NULL,
`front_axle_SAI_right_before` varchar(45) NOT NULL,
`front_axle_SAI_cross_before` varchar(45) NOT NULL,
`front_axle_SAI_left_actual` varchar(45) NOT NULL,
`front_axle_SAI_right_actual` varchar(45) NOT NULL,
`front_axle_SAI_cross_actual` varchar(45) NOT NULL,
`front_axle_track_differential_angle_left_before` varchar(45) DEFAULT NULL,
`front_axle_track_differential_angle_right_before` varchar(45) DEFAULT NULL,
`front_axle_track_differential_angle_left_actual` varchar(45) DEFAULT NULL,
`front_axle_track_differential_angle_right_actual` varchar(45) DEFAULT NULL,
`front_axle_toe_left_before` varchar(45) NOT NULL,
`front_axle_toe_right_before` varchar(45) NOT NULL,
`front_axle_toe_total_before` varchar(45) NOT NULL,
`front_axle_toe_left_actual` varchar(45) NOT NULL,
`front_axle_toe_right_actual` varchar(45) NOT NULL,
`front_axle_toe_total_actual` varchar(45) NOT NULL,
`front_axle_setback_before` varchar(45) DEFAULT NULL,
`front_axle_setback_actual` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_left_steer_left_before` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_left_steer_right_before` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_left_steer_left_actual` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_left_steer_right_actual` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_right_steer_left_before` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_right_steer_right_before` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_right_steer_left_actual` varchar(45) DEFAULT NULL,
`front_axle_max_steering_lock_right_steer_right_actual` varchar(45) DEFAULT NULL,
`technician_name` varchar(45) NOT NULL,
`inspection_date_time` datetime NOT NULL,
`vehicle_id` varchar(45) NOT NULL,
`branch_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `inspection`
--
INSERT INTO `inspection` (`inspection_id`, `rear_axle_camber_left_before`, `rear_axle_camber_right_before`, `rear_axle_camber_cross_before`, `rear_axle_camber_left_actual`, `rear_axle_camber_right_actual`, `rear_axle_camber_cross_actual`, `rear_axle_toe_left_before`, `rear_axle_toe_right_before`, `rear_axle_toe_total_before`, `rear_axle_toe_left_actual`, `rear_axle_toe_right_actual`, `rear_axle_toe_total_actual`, `rear_axle_geometrical_driving_axis_before`, `rear_axle_geometrical_driving_axis_actual`, `front_axle_camber_left_before`, `front_axle_camber_right_before`, `front_axle_camber_cross_before`, `front_axle_camber_left_actual`, `front_axle_camber_right_actual`, `front_axle_camber_cross_actual`, `front_axle_caster_left_before`, `front_axle_caster_right_before`, `front_axle_caster_cross_before`, `front_axle_caster_left_actual`, `front_axle_caster_right_actual`, `front_axle_caster_cross_actual`, `front_axle_SAI_left_before`, `front_axle_SAI_right_before`, `front_axle_SAI_cross_before`, `front_axle_SAI_left_actual`, `front_axle_SAI_right_actual`, `front_axle_SAI_cross_actual`, `front_axle_track_differential_angle_left_before`, `front_axle_track_differential_angle_right_before`, `front_axle_track_differential_angle_left_actual`, `front_axle_track_differential_angle_right_actual`, `front_axle_toe_left_before`, `front_axle_toe_right_before`, `front_axle_toe_total_before`, `front_axle_toe_left_actual`, `front_axle_toe_right_actual`, `front_axle_toe_total_actual`, `front_axle_setback_before`, `front_axle_setback_actual`, `front_axle_max_steering_lock_left_steer_left_before`, `front_axle_max_steering_lock_left_steer_right_before`, `front_axle_max_steering_lock_left_steer_left_actual`, `front_axle_max_steering_lock_left_steer_right_actual`, `front_axle_max_steering_lock_right_steer_left_before`, `front_axle_max_steering_lock_right_steer_right_before`, `front_axle_max_steering_lock_right_steer_left_actual`, `front_axle_max_steering_lock_right_steer_right_actual`, `technician_name`, `inspection_date_time`, `vehicle_id`, `branch_id`) VALUES
('D884721', '-0.09\'', '-0.78\'', '0.12\'', '-0.30\'', '-0.42\'', '0.01\'', '1.43mm', '-2.5mm', '-1.7mm', '1.5mm', '1.4mm', '3.1mm', '0.02\'', '0.01\'', '-0.08\'', '0.21\'', '-0.27\'', '0.01\'', '0.15\'', '0.02\'', '2.42\'', '1.85\'', '-0.05\'', '2.32\'', '2.20\'', '-0.02\'', '12.44\'', '12.26\'', '0.12\'', '12.40\'', '12.11\'', '0.01\'', NULL, NULL, NULL, NULL, '1.23mm', '2.4mm', '1.05mm', '0.4mm', '0.7mm', '1.2mm', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Cooper', '2018-06-05 11:20:00', '3FS8DC7AS49328328', 5),
('R005374', '-0.50\'', '-0.33\'', '-0.16\'', '-0.36\'', '-0.33\'', '-0.04\'', '0.6mm', '-2.7mm', '-2.1mm', '1.8mm', '1.7mm', '3.5mm', '0.09\'', '0.00\'', '-0.09\'', '0.22\'', '-0.31\'', '-0.01\'', '0.16\'', '-0.17\'', '2.10\'', '2.17\'', '-0.08\'', '2.10\'', '2.17\'', '-0.08\'', '12.43\'', '12.26\'', '0.17\'', '12.34\'', '12.33\'', '0.02\'', NULL, NULL, NULL, NULL, '1.7mm', '2.3mm', '3.9mm', '0.9mm', '0.8mm', '1.7mm', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Raj', '2018-02-09 09:18:00', '7AT0CJ0DX12300244', 1);
-- --------------------------------------------------------
--
-- Table structure for table `invoice`
--
CREATE TABLE `invoice` (
`invoice_id` varchar(7) NOT NULL,
`description` varchar(45) NOT NULL,
`quantity` int(11) NOT NULL,
`unit_price` float NOT NULL,
`date` date NOT NULL,
`due_date` date NOT NULL,
`customer_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `invoice`
--
INSERT INTO `invoice` (`invoice_id`, `description`, `quantity`, `unit_price`, `date`, `due_date`, `customer_id`) VALUES
('B742632', 'Batmobile Wheel Alignment', 6, 76.971, '2018-02-23', '2018-04-14', 1),
('D884721', 'Wheel alignment and charge', 2, 42.451, '2018-04-13', '2018-04-14', 5),
('R005374', 'Wheel Alignment', 1, 34.7826, '2018-02-09', '2018-02-09', 3);
-- --------------------------------------------------------
--
-- Table structure for table `owner`
--
CREATE TABLE `owner` (
`owner_id` int(11) NOT NULL,
`owner_fname` varchar(45) NOT NULL,
`owner_lname` varchar(45) NOT NULL,
`owner_phone` varchar(45) NOT NULL,
`owner_email` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `owner`
--
INSERT INTO `owner` (`owner_id`, `owner_fname`, `owner_lname`, `owner_phone`, `owner_email`) VALUES
(1, 'Bruce', 'Wayne', '0214857489', 'notbatman#waynecorp.com'),
(2, 'Thanos', 'Of Titan', '0278941578', 'thanos#allthingsbalance.org'),
(3, 'Peter', 'Parker', '0204584514', 'spider#man.com'),
(4, 'Tony', 'Stark', '0214821454', 'tony#starkindustries.com'),
(5, 'Elon', 'Musk', '0245158741', 'elon#mars.space'),
(6, 'Austin', 'Post', '0215415478', 'postmalone#rockstar.com');
-- --------------------------------------------------------
--
-- Table structure for table `targetValue`
--
CREATE TABLE `targetValue` (
`idtargetValue` int(11) NOT NULL,
`rear_axle_camber_left_right_target` varchar(45) NOT NULL,
`rear_axle_camber_cross_target` varchar(45) NOT NULL,
`rear_axle_toe_left_right_target` varchar(45) NOT NULL,
`rear_axle_toe_total_target` varchar(45) NOT NULL,
`rear_axle_geometrical_driving_axis_target` varchar(45) NOT NULL,
`front_axle_camber_left_right_target` varchar(45) NOT NULL,
`front_axle_camber_cross_target` varchar(45) NOT NULL,
`front_axle_caster_left_right_target` varchar(45) NOT NULL,
`front_axle_caster_cross_target` varchar(45) NOT NULL,
`front_axle_sai_left_right_target` varchar(45) NOT NULL,
`front_axle_sai_cross_target` varchar(45) NOT NULL,
`front_axle_track_differential_angle_left_right_target` varchar(45) DEFAULT NULL,
`front_axle_toe_left_right_target` varchar(45) NOT NULL,
`front_axle_toe_total_target` varchar(45) NOT NULL,
`front_axle_setback_target` varchar(45) NOT NULL,
`front_axle_max_steering_lock_left_steer_left_target` varchar(45) NOT NULL,
`front_axle_max_steering_lock_left_steer_right_target` varchar(45) NOT NULL,
`front_axle_max_steering_lock_right_steer_left_target` varchar(45) NOT NULL,
`front_axle_max_steering_lock_right_steer_right_target` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `targetValue`
--
INSERT INTO `targetValue` (`idtargetValue`, `rear_axle_camber_left_right_target`, `rear_axle_camber_cross_target`, `rear_axle_toe_left_right_target`, `rear_axle_toe_total_target`, `rear_axle_geometrical_driving_axis_target`, `front_axle_camber_left_right_target`, `front_axle_camber_cross_target`, `front_axle_caster_left_right_target`, `front_axle_caster_cross_target`, `front_axle_sai_left_right_target`, `front_axle_sai_cross_target`, `front_axle_track_differential_angle_left_right_target`, `front_axle_toe_left_right_target`, `front_axle_toe_total_target`, `front_axle_setback_target`, `front_axle_max_steering_lock_left_steer_left_target`, `front_axle_max_steering_lock_left_steer_right_target`, `front_axle_max_steering_lock_right_steer_left_target`, `front_axle_max_steering_lock_right_steer_right_target`) VALUES
(1, '-0.40\' +/-0.30\'', '-0.00\' +/-0.30\'', '1.5mm +/-1.0mm', '3mm +/-2.0mm', '-0.00\'', '-0.00\' +/-0.30\'', '-0.00\' +/-0.30\'', '-2.35\' +/-0.30\'', '-0.00\' +/-0.30\'', '-12.40\' +/-0.45\'', '-0.00\'', NULL, '0.5mm +/-1.0mm', '1mm +/-2.0mm', '-0.00\'', '-41.00\' +/-1.30\'', '-33.00\' +/-1.30\'', '-33.00\' +/-1.30\'', '-41.00\' +/-1.30\'');
-- --------------------------------------------------------
--
-- Table structure for table `vehicle`
--
CREATE TABLE `vehicle` (
`vehicle_id` varchar(17) NOT NULL,
`vehicle_chassis` varchar(12) NOT NULL,
`vehicle_model` varchar(45) NOT NULL,
`vehicle_make` varchar(45) NOT NULL,
`vehicle_registration` varchar(45) NOT NULL,
`vehicle_body_type` varchar(45) NOT NULL,
`vehicle_year` varchar(45) NOT NULL,
`vehicle_first_registration_date` date NOT NULL,
`vehicle_odometer_reading` int(11) NOT NULL,
`owner_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `vehicle`
--
INSERT INTO `vehicle` (`vehicle_id`, `vehicle_chassis`, `vehicle_model`, `vehicle_make`, `vehicle_registration`, `vehicle_body_type`, `vehicle_year`, `vehicle_first_registration_date`, `vehicle_odometer_reading`, `owner_id`) VALUES
('2CR2DF3AC45100214', 'AA1D-8001541', 'Prius', 'Toyota', 'Q3WFV2', 'Sedan', '2012', '2013-02-06', 152014, 2),
('3FS8DC7AS49328328', 'DD6C-7842102', 'Roadster', 'Tesla', 'TOMARS', 'Roadster', '2008', '2008-07-04', 180454, 5),
('6XD8DC7AS28228087', 'AB2K-7833861', 'Batmobile', 'Waynecorp', 'THEBAT', 'Hero Car', '2018', '2018-02-04', 100000, 1),
('7AT0CJ0DX12300244', 'CS2W-0300244', 'Lancer', 'Mistsubishi', 'DCF254', 'Station Wagon', '2007', '2007-05-01', 147245, 3);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `branch`
--
ALTER TABLE `branch`
ADD PRIMARY KEY (`branch_id`);
--
-- Indexes for table `inspection`
--
ALTER TABLE `inspection`
ADD PRIMARY KEY (`inspection_id`),
ADD KEY `vehicle_inspection_fk_idx` (`vehicle_id`),
ADD KEY `branch_inspection_fk_idx` (`branch_id`);
--
-- Indexes for table `invoice`
--
ALTER TABLE `invoice`
ADD PRIMARY KEY (`invoice_id`),
ADD KEY `customer_invoice_fk_idx` (`customer_id`);
--
-- Indexes for table `owner`
--
ALTER TABLE `owner`
ADD PRIMARY KEY (`owner_id`);
--
-- Indexes for table `targetValue`
--
ALTER TABLE `targetValue`
ADD PRIMARY KEY (`idtargetValue`);
--
-- Indexes for table `vehicle`
--
ALTER TABLE `vehicle`
ADD PRIMARY KEY (`vehicle_id`),
ADD KEY `owner_vehicle_fk_idx` (`owner_id`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `inspection`
--
ALTER TABLE `inspection`
ADD CONSTRAINT `branch_inspection_fk` FOREIGN KEY (`branch_id`) REFERENCES `branch` (`branch_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `vehicle_inspection_fk` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`vehicle_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `invoice`
--
ALTER TABLE `invoice`
ADD CONSTRAINT `customer_invoice_fk` FOREIGN KEY (`customer_id`) REFERENCES `owner` (`owner_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Constraints for table `vehicle`
--
ALTER TABLE `vehicle`
ADD CONSTRAINT `owner_vehicle_fk` FOREIGN KEY (`owner_id`) REFERENCES `owner` (`owner_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
/*!40101 SET CHARACTER_SET_CLIENT=#OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=#OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=#OLD_COLLATION_CONNECTION */;
that means you have no Database created. You should create database first. The query will be like this:
CREATE DATABASE yourDatabaseName
After you create your database, you can double click the database that you have created in a left panel (The header name is "SCHEMAS").
If you are facing this issue when you have created a database, you can try this query:
USE yourDatabaseName;
Your CREATE TABLE Query;
Double click on the first title which you see under 'SCHEMAS'.
The way to know it is it should turn into bold letters.

Speed up MySQL that contains a large table

We have a MySQL table hosted on an Amazon AWS server, which is some times very very slow while querying. I'm considering restructuring the table with better indexing and columns data types.
Here is the create table structure :
SHOW CREATE TABLE export_users;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| exportusers | CREATE TABLE `exportusers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`UAccountID` varchar(50) CHARACTER SET utf8 NOT NULL,
`ApplyURL` text,
`CityName` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`ClassList` text,
`UCompanyID` varchar(20) DEFAULT NULL,
`UContactCompany` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`UContactEmail` varchar(512) CHARACTER SET utf8 DEFAULT NULL,
`UContactFax` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`UContactName` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`UContactPhone` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`CountryName` char(2) CHARACTER SET utf8 NOT NULL,
`DateCreated` datetime NOT NULL,
`DateModified` datetime NOT NULL,
`DateSysCreated` datetime NOT NULL,
`DateSysModified` datetime NOT NULL,
`DegreeCode` varchar(200) DEFAULT NULL,
`DegreeCodeDecoded` varchar(512) CHARACTER SET utf8 DEFAULT NULL,
`DisplayCity` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`DisplayuserID` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`ExperienceCode` varchar(200) DEFAULT NULL,
`ExperienceCodeDecoded` text,
`ExternalKey` varchar(32) CHARACTER SET utf8 DEFAULT NULL,
`GeoUSZip5` varchar(5) DEFAULT NULL,
`HostSite` char(2) CHARACTER SET utf8 NOT NULL,
`IndustryCode` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`IndustryCodeDecoded` text,
`IsBOFuser` tinyint(1) DEFAULT NULL,
`IsDiversityuser` tinyint(1) DEFAULT NULL,
`userID` varchar(20) NOT NULL,
`userDesc` text,
`userFunctionCode` text,
`userFunctionCodeDecoded` text,
`userReq` text,
`userSkinDID` varchar(20) DEFAULT NULL,
`userTitle` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`userType` varchar(512) CHARACTER SET utf8 DEFAULT NULL,
`userTypeDesc` text,
`userTypeCodeDecoded` text,
`Latitude` decimal(10,5) DEFAULT NULL,
`Longitude` decimal(10,5) DEFAULT NULL,
`Location` varchar(70) CHARACTER SET utf8 DEFAULT NULL,
`ManagementCode` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
`MaximumExp` int(11) DEFAULT NULL,
`MinimunExp` int(11) DEFAULT NULL,
`Onet` varchar(10) DEFAULT NULL,
`OnetTitle` text,
`BeginDate` datetime NOT NULL,
`EndDate` datetime NOT NULL,
`PayBaseH` decimal(10,2) DEFAULT NULL,
`PayBaseL` decimal(10,2) DEFAULT NULL,
`PayBonus` decimal(10,2) DEFAULT NULL,
`PayComm` decimal(10,2) DEFAULT NULL,
`PayOther` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
`PayPer` varchar(8) DEFAULT NULL,
`PayType` char(3) DEFAULT NULL,
`PostalCode` varchar(10) DEFAULT NULL,
`PostingPath` varchar(20) NOT NULL,
`Relocate` tinyint(1) DEFAULT NULL,
`RelocateOptions` varchar(5) DEFAULT NULL,
`ScreenerID` varchar(20) DEFAULT NULL,
`SiteID` varchar(1024) CHARACTER SET utf8 DEFAULT NULL,
`SliceList` text,
`StateName` char(30) CHARACTER SET utf8 DEFAULT NULL,
`Status` varchar(50) NOT NULL,
`TextPay` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
`TotalPay` decimal(10,2) DEFAULT NULL,
`TownName` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`TravelCode` varchar(200) DEFAULT NULL,
`TravelCodeDecoded` text,
`UpgradeList` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_jobs_on_UAccountID` (`UAccountID`),
KEY `index_jobs_on_CountryName` (`CountryName`),
KEY `index_jobs_on_DateCreated` (`DateCreated`),
KEY `index_jobs_on_DateModified` (`DateModified`),
KEY `index_jobs_on_DateSysCreated` (`DateSysCreated`),
KEY `index_jobs_on_DateSysModified` (`DateSysModified`),
KEY `index_jobs_on_HostSite` (`HostSite`),
KEY `index_jobs_on_userID` (`userID`),
KEY `index_jobs_on_BeginDate` (`BeginDate`),
KEY `index_jobs_on_EndDate` (`EndDate`),
KEY `index_jobs_on_PostingPath` (`PostingPath`),
KEY `index_jobs_on_Status` (`Status`)
) ENGINE=InnoDB AUTO_INCREMENT=7907436 DEFAULT CHARSET=utf8mb4 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.27 sec)
Consider Normalization of your schema. Breaking up that one very large entity into much smaller related entities will have the greatest impact on your querying speed.
Normalization involves decomposing a table into less redundant (and smaller) tables but without losing information; defining foreign keys in the old table referencing the primary keys of the new ones. The objective is to isolate data so that additions, deletions, and modifications of an attribute can be made in just one table and then propagated through the rest of the database using the defined foreign keys.

Issue converting table from InnoDB to MyISAM (there can be only one auto column and it must be defined as a key)

I'm having issues trying to convert a table from MyISAM to InnoDB in MySQL 5.6.
The following is the table dump:
--
-- Table structure for table `companies`
--
DROP TABLE IF EXISTS `companies`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `companies` (
`uid` int(20) NOT NULL,
`cid` int(20) NOT NULL AUTO_INCREMENT,
`cname` varchar(500) NOT NULL,
`rfc` varchar(20) NOT NULL,
`address` varchar(1000) NOT NULL,
`dbUseExternal` tinyint(1) NOT NULL DEFAULT '0',
`dbHost` varchar(50) NOT NULL,
`dbPort` varchar(50) NOT NULL,
`dbUser` varchar(50) NOT NULL,
`dbPass` varchar(50) NOT NULL,
`dbSSL` varchar(50) NOT NULL,
`dbDriver` varchar(50) NOT NULL,
`dbName` varchar(50) NOT NULL,
`status` int(10) NOT NULL,
PRIMARY KEY (`uid`,`cid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
It works as MyISAM. But, if I try to convert it to InnoDB (or if I try editing this dump to insert it on the command line as a SQL file), I get the following error:
Incorrect table definition; there can be only one auto column and it must be defined as a key
I understand that error - or at least I thought I did. I'm not really using more than one AUTO_INCREMENT column and it is defined as primary key.
Also, the information I've found regarding the error is always because of an obvious missing key or a duplicate AUTO_INCREMENT definition. One more thing I see generally commented is that the same is true for MyISAM and InnoDB.
So, why does it work for MyISAM and not for InnoDB?
in InnoDB, auto_increment keys have to have to: either have their own index, or at least be the primary sub-index of a compound index. (a in KEY(a,b)).
Fix this by adding a KEY(cid) after your PRIMARY KEY, like so:
CREATE TABLE `companies2` (
`uid` int(20) NOT NULL,
`cid` int(20) NOT NULL AUTO_INCREMENT,
`cname` varchar(500) NOT NULL,
`rfc` varchar(20) NOT NULL,
`address` varchar(1000) NOT NULL,
`dbUseExternal` tinyint(1) NOT NULL DEFAULT '0',
`dbHost` varchar(50) NOT NULL,
`dbPort` varchar(50) NOT NULL,
`dbUser` varchar(50) NOT NULL,
`dbPass` varchar(50) NOT NULL,
`dbSSL` varchar(50) NOT NULL,
`dbDriver` varchar(50) NOT NULL,
`dbName` varchar(50) NOT NULL,
`status` int(10) NOT NULL,
PRIMARY KEY (`uid`,`cid`),
KEY(`cid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;