The ability and manner in which a table column may be specified with a default empty string appears to be RDBMS implementation dependent.
This answer (default a column with empty string) and this one (Avoid NULL columns using DEFAULT Empty String) indicate that a default empty string may be set with a CREATE TABLE column rule that uses an empty single-quoted literal with the DEFAULT constraint.
Here is a DDL excerpt that I have used in HSQLDB 2.2.9. I am executing SQL against the database with SQuirreL 3.4.0:
CREATE CACHED TABLE Clients (
cli_id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
mRN VARCHAR(24) NOT NULL UNIQUE,
lastName VARCHAR(48) NOT NULL,
midName VARCHAR(24),
firstName VARCHAR(24) DEFAULT '' NOT NULL,
);
lastName may not be NULL
midName has no column rules
firstName is not nullable and an attempt is made to have it default to an empty string by specifying an empty string literal as suggested by the previous answers.
When I use SQuirreL to make this table editable and then insert a row into the table, the following values appear in the columns:
lastName: (empty)
midName: <null>
firstName: ''
It seems that the semantics DEFAULT '' NOT NULL in HSQLDB cause the column to default to two single quotes and not to an empty string. When the column rule NOT NULL is used alone without a DEFAULT rule, it looks as though an empty string is reported by SQuirreL when a new row is inserted.
Can someone confirm that the correct way to have a VARCHAR column in HSQLDB default to a non-null, empty, zero-length string is to use these semantics:
CREATE CACHED TABLE Clients (
cli_id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
mRN VARCHAR(24) NOT NULL UNIQUE,
lastName VARCHAR(48) NOT NULL,
midName VARCHAR(24) NOT NULL,
firstName VARCHAR(24) NOT NULL,
);
Thanks :-)