Search code examples
csvmysql-workbenchprimary-keylinux-mint-21

Primary key issue of a table imported from CSV, using MySQL Workbench (Linux Mint 21 Vanessa)


I'm using "Table Data Import Wizard" of MySQL Workbench to import some CSV files. All of these files bring first column with only exclusive VALUES, so they're kind of primary keys (PK) to after be used as linkage anchors among other peer tables.

I observed that besides imported table doesn't present a "formal PK", property checked with the use of Table Inspector, it isn't possible to select the first COLUMN neither to establish JOINS with other tables (what I can do when use SQLite Browser to import same CSV files and assemble my queries).

My idea was then to insert an "post import pk" aiming to have the issue solved, after googling here and there I came to:

ALTER TABLE `Antaq`.`2023CargaN` ADD COLUMN `id_post` int PRIMARY KEY AUTO_INCREMENT FIRST;

Using Table Inspector again, noticed that it was included on the leftest position of table, as a true PK, what can be likewise observed by typing:

SELECT * FROM `Antaq`.`2023CargaN`;

But I still can't select the leftiest original column (IDCarga), but it's possible to select new "formal PK" that I've inserted (id_post):

SELECT id_post FROM `Antaq`.`2023CargaN`; /*I get a table response*/
SELECT IDCaga FROM `Antaq`.`2023CargaN`;  /*No response */

Does anybody have an idea of what kind of primary mistake I'm committing? It has already took me a lot of time...


Solution

  • I also made a test with Win10, and after some warns the table worked fine. Then I start suspescting it could be a badd formation of CSV, then I tried to pass it through GSheets and download back to machine.

    After doing this way it worked fine, bur GSheets did the job. So I must search how identify what problem is happening as I had large tables that can´t pass through GSeets.