Things To Do When Import CSV into MySQL Workbench to Create New Table

In the below example, I have imported 2 CSV's into MySQL Workbench. One to create the table 'cc_to_qtree' the other 'cc_to_business_entity'.

The import-and-create-table does not automatically create primary keys or indexes, so you need to add these. If MySQL Workbench imported a column as 'text' (or BLOB) then you need to modify the type to VARCHAR before it can be a primary key or index.

show create table cc_to_qtree;
show create table cc_to_business_entity;
ALTER TABLE cc_to_qtree ADD PRIMARY KEY(`id`);
ALTER TABLE cc_to_qtree MODIFY `Cost Code` VARCHAR(255);
ALTER TABLE cc_to_business_entity MODIFY `costcode` VARCHAR(255);
ALTER TABLE cc_to_business_entity ADD PRIMARY KEY(`costcode`);
CREATE INDEX idx1 ON cc_to_qtree (`Cost Code`);





Comments