Powered by SmartDoc

columnName

The extention syntax columnName specifies a column name for a target column.

Target

The target of the columnName attribute is the property for the column name.

Parameters

The columnName attribute takes a string value for a column name.

Artifact

If true, the value of the columnName attribute is used for a colum name for the target column in the DDL.

Example

List 13.6.4.1[columnName.rng] is a sample schema for the columnName attribute.

columnName.rng
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         xmlns:sql="http://www.relaxer.org/xmlns/relaxer/sql"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <ref name="account"/>
  </start>
  <define name="account">
    <element name="account">
      <attribute name="accountNo" sql:columnName="ACCOUNT_NO">
        <data type="token"/>
      </attribute>
      <element name="balance">
        <data type="int"/>
      </element>
      <element name="owner">
        <data type="token"/>
      </element>
      <ref name="address"/>
      <zeroOrMore>
        <ref name="phone"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="address">
    <element name="address">
      <attribute name="zip">
        <data type="token"/>
      </attribute>
      <text/>
    </element>
  </define>
  <define name="phone">
    <element name="phone">
      <attribute name="area">
        <data type="token"/>
      </attribute>
      <data type="token"/>
    </element>
  </define>
</grammar>

In the schema, the extension attribute sql:columnName is specified in the element named accountNo. This definition means that the column name for the column is ACCOUNT_NO.

Execution of Relaxer with the columnName attribute is as follows. No special options are required.

$ relaxer -jdbc columnName.rng

As a result, Relaxer generates 13 files:

The file account.ddl, in List 13.6.4.2[account.ddl], shows the effect of the columnName attribute. A column name derived from the property accountNo becomes ACCOUNT_NO.

account.ddl
CREATE TABLE "account" (
	"ACCOUNT_NO" VARCHAR(32) NOT NULL,
	"balance" INTEGER NOT NULL,
	"owner" VARCHAR(32) NOT NULL,
	"address" VARCHAR(128) NOT NULL,
	"address_zip" VARCHAR(32) NOT NULL,
	"phone" VARCHAR(512)
)