Reputation: 672
When creating a Firebird database with the SQL below, it doesn't follow the default collation specified. But if I then alter the default collation after the database is created it works.
This creates a database that has a default collation of UTF8. I've tried leaving out the parameter for CharacterSet but that will create a database with not character set instead of the character set provided by the sql statement.
edit: Adding component setup
fConnection.Params.Add(Format('DriverID=%s', ['IB']));
fConnection.Params.Add(Format('Database=%s', [vDBFile]));
fConnection.Params.Add(Format('CharacterSet=%s', ['UTF8']));
fConnection.Params.Add(Format('user_name=%s', ['sysdba']));
fConnection.Params.Add(Format('password=%s', ['masterkey']));
fConnection.Params.Add(Format('ExtendedMetadata=%s', ['True']));
fConnection.Params.Add(Format('CreateDatabase=%s', ['Yes']));
fConnection.Params.Add(Format('Protocol=%s', ['TCPIP']));
fConnection.Params.Add(Format('Server=%s', [pInfo.xServer]));
vScript := TADScript.Create(nil);
vScript.Connection := fConnection;
vScript.Transaction := fTransaction;
vScript.SQLScripts.Add.SQL.Text :=
{leaving out quotes for readability}
SET SQL DIALECT 3;
SET CLIENTLIB 'c:\Firebird\fbclient.dll';
CREATE DATABASE 'TEST'
USER 'sysdba' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
vScript.ValidateAll;
vScript.ExecuteAll;
Executing the following SQL after the database is created will change the default collation to UNICODE_CI_AI
ALTER CHARACTER SET UTF8 SET DEFAULT COLLATION UNICODE_CI_AI
What SQL should I be using so that the default collation is set properly on database create?
I'm currently using Firebird 2.5.5 and accessing it from Delphi 2006 with the AnyDac components.
Upvotes: 3
Views: 1091