Page 1 of 1
MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Tue Nov 27, 2018 6:54 pm
by Otto
Hello
I would like to make an array to create following SQL sting.
CREATE TABLE `bookings` (
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`text` text DEFAULT NULL,
`room` int(11) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`id` int(11) NOT NULL,
`is_paid` tinyint(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Can someone please show me how I can create:
Text, int(11) and tinyint(1).
`text` text DEFAULT NULL,
`is_paid` tinyint(1) DEFAULT NULL
`status` int(11) DEFAULT NULL,
local aStru := { ;
{ "start_date", "D", 8, 0 }, ;
{ "end_date", "D", 8, 0 }, ;
{ "text", "C", 30, 0,"latin1" }, ;
{ "room", "N", 4, 0 }, ;
{ "status", "N", 5, 0 }, ;
{ "idPrimary", "+", 3, 0 }, ; // '+' : AutoInc Primary Key
{ "is_paid", "N", 6, 0 } }
Thank you in advance
Otto
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Wed Nov 28, 2018 10:16 am
by Otto
Hello,
As I do not know the right syntax for for oCn:CreateTable( cTable, aStru ) I use oCn:Execute( cSql ) and pass the SQL string.
This is working for me.
Mr Rao documented FWH -
Built-in MySql/MariaDB functionality very well.
Thank you for creating the LIB and your great work on the LIB.
I put the link here again – sometimes you miss such important information as you do not need it immediately
viewtopic.php?f=3&t=32657&p=191922&hilit=http%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2F#p191922Best regards
Otto
cSql := "CREATE TABLE `planner` ( `start_date` date DEFAULT NULL, `end_date` date DEFAULT NULL, `text` text DEFAULT NULL, `room` int(11) DEFAULT NULL, `status` int(11) DEFAULT NULL, `id` int(11) NOT NULL, `is_paid` tinyint(1) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
oCn:Execute( cSql )
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Wed Nov 28, 2018 10:18 am
by nageswaragunupudi
Code: Select all | Expand
MYSQL_TinyIntAsLogical( .t. )
aStru := { ;
{ "start_date", "D", 8, 0 }, ;
{ "end_date", "D", 8, 0 }, ;
{ "text", "C", 30, 0,"latin1" }, ;
{ "room", "N", 5, 0 }, ;
{ "status", "N", 5, 0 }, ;
{ "idPrimary", "+", 3, 0 }, ;
{ "is_paid", "L", 1, 0 } }
oCn:DropTable( "rooms" )
oCn:CreateTable( "rooms", aStru, , "latin1" )
? oCn:CreateTableSQL( "rooms" )
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Tue Sep 28, 2021 7:52 pm
by goosfancito
Hola.-
Code: Select all | Expand
::oCnx:DropTable( "tbsucursal" )
aDatos := { ;
{ "id", "n", 2, 0, "PRI" }, ;
{ "nombre", "c", 120, 0 } ;
}
lValue := ::oCnx:createtable( "tbsucursal", aDatos, .t. )
IF ( lValue )
::oCnx:insert( "tbsucursal", "nombre", { "Reconquista" } )
::oCnx:insert( "tbsucursal", "nombre", { "Rafaela" } )
ENDIF
al hacer:
no me funciona el indice primario "id" que estoy haciendo mal?
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Wed Sep 29, 2021 2:30 am
by nageswaragunupudi
Code: Select all | Expand
::oCnx:DropTable( "tbsucursal" )
aDatos := { ;
{ "nombre", "C", 120, 0 } ;
}
lValue := ::oCnx:createtable( "tbsucursal", aDatos )
IF ( lValue )
::oCnx:insert( "tbsucursal", "nombre", { "Reconquista" } )
::oCnx:insert( "tbsucursal", "nombre", { "Rafaela" } )
ENDIF
xbrowser ::oCnx:tbsucursal
? ::oCnx:CreateTableSQL( "tbsucursal" )
Please use capitals for field datatypes, like "N","C","L","D","T","M".
Do not use "n","c","l","d","t"
In some cases Upper and Lower cases have different significance.
"C" : Creates VarChar
"c" : Creates Binary char field
"M" : Creates Long Text Field
"m" : Creates Long BLOB
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Thu Nov 04, 2021 2:24 pm
by horacio
Hi Rao
"C" : Creates VarChar
"c" : Creates Binary char field
"M" : Creates Long Text Field
"m" : Creates Long BLOB
where can you see all the options? Thank you
Saludos