28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

creation, but can have any number of rows. Database tables also typically have meta-data associated with them;<br />

the meta-data might include constraints on the table or on the values within particular columns.<br />

<strong>SAP</strong> <strong>HANA</strong> Extended Application Services (<strong>SAP</strong> <strong>HANA</strong> XS) enables you to create a database table as a designtime<br />

file in the repository. All repository files including your table definition can be transported to other <strong>SAP</strong> <strong>HANA</strong><br />

systems, for example, in a delivery unit.<br />

Note: A delivery unit is the medium <strong>SAP</strong> <strong>HANA</strong> provides to enable you to assemble all your applicationrelated<br />

repository artifacts together into an archive that can be easily exported to other systems.<br />

If your application is configured to use the design-time version of a database table in the repository rather than<br />

the runtime version in the catalog, any changes to the repository version of the table are visible as soon as they<br />

are committed to the repository. There is no need to wait for the repository to activate a runtime version of the<br />

table.<br />

The following code illustrates a simple example of a design-time table definition:<br />

table.schemaName = "MYSCHEMA";<br />

table.tableType = COLUMNSTORE;<br />

table.columns = [<br />

{name = "Col1"; sqlType = VARCHAR; nullable = false; length = 20;<br />

comment = "dummy comment";},<br />

{name = "Col2"; sqlType = INTEGER; nullable = false;},<br />

{name = "Col3"; sqlType = NVARCHAR; nullable = true; length = 20;<br />

defaultValue = "Defaultvalue";},<br />

{name = "Col4"; sqlType = DECIMAL; nullable = false; precision = 2;<br />

scale = 3;}];<br />

table.indexes = [<br />

{name = "MYINDEX1"; unique = true; indexColumns = ["Col2"];},<br />

{name = "MYINDEX2"; unique = true; indexColumns = ["Col1", "Col4"];}];<br />

table.primaryKey.pkcolumns = ["Col1", "Col2"];<br />

If you want to create a database table as a repository file, you must create the table as a flat file and save the file<br />

containing the table dimensions with the suffix .hdbtable, for example, MYTABLE.hdbtable. The new file is<br />

located in the package hierarchy you establish in the <strong>SAP</strong> <strong>HANA</strong> repository. You can activate the repository files at<br />

any point in time.<br />

Note: On activation of a repository file, the file suffix, for example, .hdbtable, is used to determine which<br />

runtime plugin to call during the activation process. The plugin reads the repository file selected for<br />

activation, in this case a table, parses the object descriptions in the file, and creates the appropriate<br />

runtime objects.<br />

5.4 Creating Tables<br />

<strong>SAP</strong> <strong>HANA</strong> Extended Application Services (<strong>SAP</strong> <strong>HANA</strong> XS) enables you to create a database table as a designtime<br />

file in the repository.<br />

To create a table file in the repository, perform the following steps:<br />

1. Start the <strong>SAP</strong> <strong>HANA</strong> studio.<br />

2. Open the <strong>SAP</strong> <strong>HANA</strong> Development perspective.<br />

3. Open the Project Explorer view.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Setting Up the Persistence Model<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved. 77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!