Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to modify the database definition (DDL)

The DDL statements are those that modify the database definition, i.e. the CREATE, ALTER and DROP statements. These are equivalent to using the functional interface provided by the RDbDatabase and RDbIncremental classes for the corresponding operation. However, the SQL statements may not provide the full flexibility of the functional API.

You can create a table using the CreateTable() function of the RDbDatabase class:

_LIT(KId,"Id");
_LIT(KSupplierName,"SupplierName");
_LIT(KSuppliers,"Suppliers");
...
CDbColSet* colset=CDbColSet::NewL();
TDbCol id(KId,EDbColInt32);
id.iAttributes=id.EAutoIncrement;
colset->AddL(id);
colset->AddL(TDbCol(KSupplierName,EDbColText,30));
database.CreateTable(KSuppliers,*colset);
delete colset;

Alternatively you can use the CREATE SQL statement:

_LIT(KSQLText,"CREATE TABLE Suppliers (Id COUNTER, SupplierName CHAR(30)");
...
database.Execute(KText);