HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

how to set default charset while create new field

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
fieldwhilenewcreatedefaulthowcharsetset

Problem

Is there any command in mysql that makes the following:
if I create a new field and I set the type to TEXT than it automatically knows that by this I mean not latin1_swedish_ci but utf8_hungarian_ci charset.

I would like to apply this changes to the whole database without create a new table.

Solution

You can specify this option in a field definition - CREATE TABLE Syntax, ALTER TABLE Syntax.
Try this ALTER statement -

ALTER TABLE table1
  ADD COLUMN column2 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_hungarian_ci DEFAULT NULL AFTER column1;

Code Snippets

ALTER TABLE table1
  ADD COLUMN column2 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_hungarian_ci DEFAULT NULL AFTER column1;

Context

StackExchange Database Administrators Q#12028, answer score: 4

Revisions (0)

No revisions yet.