Para crear tablas usamos la sentencia CREATE TABLE
1) podemos usar un string con toda la sentencia y en enviarla al METHOD Execute
To Create tables we use CREATE TABLE we can use a string with all sentence and send to METHOD Execute
cQuery = "CREATE TABLE absence( student_id INT UNSIGNED NOT NULL, "
cQuery += "date DATE NOT NULL,"
cQuery += "PRIMARY KEY (student_id, date), "
cQuery += "FOREIGN KEY (student_id) REFERENCES student (student_id)"
cQuery += ") ENGINE = InnoDB"
oServer:Execute( cQuery )
2) O, usar el METHOD CreateTable( cTable, aStruct, [cPrimaryKey], [cUniqueKey], [cAuto], [cExtra], [lIfNotExist],[lVer] )
Or, To use METHOD CreateTable( cTable, aStruct, [cPrimaryKey], [cUniqueKey], [cAuto], [cExtra], [lIfNotExist],[lVer] )
cTable El nombre de la tabla en la Base de Datos
name table in Database
aStruct Esrtructura parecida a la usada en DBF con el siguiente formato
Stucture like DBF with this format
{ Name, Type, Length, Decimal, Not Null (logical), Defaul value }
cPrimaryKey Nombre del campo que sera PRIMARY KEY
field name PRIMARY KEY
cUniqueKey Nombre del campo que sera UNIQUE
field name UNIQUE
cAuto Nombre del campo que sera AUTO INCREMENT
field name AUTO INCREMENT
cExtra sentencias despues de la definicion de campos
statements after field definitions
aMemberSt = { { "member_id" , "N", 10, 0, .T., 0 },;
{ "last_name" , "C", 20, 0, .T., } ,;
{ "first_name", "C", 20, 0, .T., } ,;
{ "suffix" , "C", 5, 0, .F., } ,;
{ "expiration", "D", 10, 0, .F., } ,;
{ "email" , "C",100, 0, .F., } ,;
{ "street" , "C", 50, 0, .F., } ,;
{ "city" , "C", 50, 0, .F., } ,;
{ "state" , "C", 2, 0, .F., } ,;
{ "zip" , "C", 10, 0, .F., } ,;
{ "phone" , "C", 20, 0, .F., } ,;
{ "interests" , "C",255, 0, .F., } }
oServer:CreateTable( "member", aMemberSt, "member_id", , "member_id", "ENGINE = InnoDB" )
========================================================
sample...
Download Sample
No hay comentarios:
Publicar un comentario