Problem with special char insertion via prompt

Asked

Viewed 41 times

2

Dear, I have a table where I do some Inserts with data containing special char. Currently I use Toad for Mysql, and when I do the insertion by this editor, everything happens correctly, the special chars go up normally, but if I use the source @script.sql of mysql command line to move the same data up, these do not go up the special chars, and yes, another char. I’d like to know how to climb up the prompt the same way I climb up the Toad.

Table:

DROP TABLE

IF EXISTS DOBER.FINANCEIRO_TRANSPORTADORA;
CREATE TABLE DOBER.FINANCEIRO_TRANSPORTADORA (
    TRANSPK INT (3) NOT NULL AUTO_INCREMENT
    ,CODIGO INT (3) NOT NULL
    ,NATUREZA VARCHAR(16)
    ,NOME VARCHAR(50) NOT NULL
    ,DATA_MODIF DATETIME
    ,USUARIO VARCHAR(10)
    ,PRIMARY KEY (TRANSPK)
    ) DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

INSERT:

INSERT INTO DOBER.FINANCEIRO_TRANSPORTADORA(
CODIGO,
NATUREZA,
NOME,
DATA_MODIF,
USUARIO) VALUES
(1,'Pessoa Jurídica','TRANSPORTADORA1',NOW(),'Usuario1'),
(2,'Pessoa Jurídica','TRANSPORTADORA2',NOW(),'Usuario2')

    Resultado com o Toad:
1  |  Pessoa Jurídica  |  TRANSPORTADORA1  |  30/10/2014 13:46:51  |  Usuario1
2  |  Pessoa Jurídica  |  TRANSPORTADORA2  |  30/10/2014 13:46:51  |  Usuario2

Resultado com MySqlCommand:
1  |  Pessoa Jurídica  |  TRANSPORTADORA1  |  30/10/2014 13:46:51  |  Usuario1
2  |  Pessoa Jurídica  |  TRANSPORTADORA2  |  30/10/2014 13:46:51  |  Usuario2
  • Use the Notepad++ and the file is with UTF-8 encoding

  • 1

    The default Mysql encoding may be interfering (if not UTF-8). Experiment pass parameter --default-character-set=utf8. http://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html#option_mysql_default-Character-set

  • Try trading single quotes for double quotes.

  • Caffé, this last comment was the solution, I inserted the --default-Character-set=utf8 at the time of connection and everything was inserted correctly.

  • Cool. I was updating my answer. Anyway if the file is not in UTF-8 you will also have problem.

1 answer

2


The character encoding of your table is UTF-8.

Your publisher Toad for Mysql must be using this same encoding and therefore the INSERT works as expected.

Browse to save the text file containing the INSERT (this used via command line) also with encoding UTF-8. This should solve the problem.

Using the text editor Notepad++ you are able to select this encoding.

In addition, you may need to inform the encoding in which the file should be interpreted (if the Mysql default or Mysql client is not set to UTF-8). In this case, pass the parameter:

--default-character-set=utf8

Behold: 4.5.1.1 mysql Options.

  • Thank you!!!!!!!!!!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.