Anybody has ideas, how to add a column meant for storing UTF-8 content in MySQL?
I tried the following:
ALTER TABLE tname ADD COLUMN cname TEXT CHARACTER SET utf8 COLLATE utf8_general_ci IF NOT EXISTS;
That gives an error:
ERROR 1064 (42000): 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 'if not exists' at line 1
I want to add a new column with UTF-8 encoding.
Thanks.
To change the character set encoding to UTF-8 for the database itself, type the following command at the mysql> prompt. Replace dbname with the database name: Copy ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci; To exit the mysql program, type \q at the mysql> prompt.
Use ADD to add new columns to a table, and DROP to remove existing columns. DROP col_name is a MySQL extension to standard SQL. To add a column at a specific position within a table row, use FIRST or AFTER col_name . The default is to add the column last.
Insert columnOpen the table structure view ( ⌘ + ^ + ] ) Click on the + Column button at the bottom, or double click on the blank row under column section, or use shortcut key ⌘ + I when selecting a column.
This is not a valid syntax for ALTER TABLE.
Here is the correct way:
ALTER TABLE tname ADD COLUMN cname TEXT CHARACTER SET utf8 COLLATE utf8_general_ci;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With