For creating table using liquibase you can use below code and add it in your liquibase file.
The use is pretty simple it's the way it looks :
Tag:
<createTable></createTable>
This is an opening/ending tag for creating a table. These tags will enclose column sub tags which will define columns for the table.
schemaName : Name of the table schema
tablespace : Name of the tablespace where you want to create the table.
remarks : A small description of the table.
Sub Tag:
<column> : It's a self terminating tag or you can use ending tag like '</column>'.
Attributes used in the above code:
name: Name of the column.
type: This defines the data type of the column
Optional Attributes:
value : The value that will be set to the column. The value is surrounded by quotes.
valueNumeric : Numeric value will be set to the column. The value is not surrounded by quotes.
valueBoolean : Boolean value (true/false) will be set to the column. The actual value string inserted will be dependent on the database implementation.
valueDate : Date/Time value will be set to the value.Supported format - "YYYY-MM-DD","hh:mm:ss" or "YYYY-MM-DDThh:mm:ss".
valueComputed : A value will be set to the column that is returned by a function or a procedure call.
defaultValue : If there is no value set to the column then the value set for this attribute will be set automatically.
defaultValueNumeric : Numeric value will be set as a default value.
defaultValueBoolean : Boolean value will be set as a default value.
Reference : http://www.liquibase.org/manual/column
Other links that you might like :
liquibase.exception.LockException: Could not acquire change log lock.
How databasechangeloglock and databasechangelog table used by liquibase?
<createTable tableName=“employee”>
<column name="id" type="int">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="first_name" type="varchar(255)"/>
<column name="last_name" type="varchar(255)"/>
<column name="username" type="varchar(255)">
<constraints unique="true" nullable="false"/>
</column>
</createTable>
The use is pretty simple it's the way it looks :
Tag:
<createTable></createTable>
This is an opening/ending tag for creating a table. These tags will enclose column sub tags which will define columns for the table.
Attribute:
tableName : Name of the table which you want to create. (This is a mandatory field)schemaName : Name of the table schema
tablespace : Name of the tablespace where you want to create the table.
remarks : A small description of the table.
Sub Tag:
<column> : It's a self terminating tag or you can use ending tag like '</column>'.
Attributes used in the above code:
name: Name of the column.
type: This defines the data type of the column
Optional Attributes:
value : The value that will be set to the column. The value is surrounded by quotes.
valueNumeric : Numeric value will be set to the column. The value is not surrounded by quotes.
valueBoolean : Boolean value (true/false) will be set to the column. The actual value string inserted will be dependent on the database implementation.
valueDate : Date/Time value will be set to the value.Supported format - "YYYY-MM-DD","hh:mm:ss" or "YYYY-MM-DDThh:mm:ss".
valueComputed : A value will be set to the column that is returned by a function or a procedure call.
defaultValue : If there is no value set to the column then the value set for this attribute will be set automatically.
defaultValueNumeric : Numeric value will be set as a default value.
defaultValueBoolean : Boolean value will be set as a default value.
defaultValueDate : Default value for Date/Time can be provided using this attribute. The format remains same as the format define for "valueDate".
defaultValueComputed : The value returned by a function or a procedure call will be set as the default value for the column.
autoIncrement : setting the value as true/false will set the columns as auto-increment.They are ignored by the databases that do not support auto-increment fuctionality.
remarks : Short description of the column.
Reference : http://www.liquibase.org/manual/column
Other links that you might like :
liquibase.exception.LockException: Could not acquire change log lock.
How databasechangeloglock and databasechangelog table used by liquibase?
Comments
Post a Comment
.