FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MariaDB - CREATE TABLE | text, int(11), tinyint
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Tue Nov 27, 2018 06:54 PM

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

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Wed Nov 28, 2018 10:16 AM
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#p191922


Best 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 )
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Wed Nov 28, 2018 10:18 AM
Code (fw): Select all Collapse
   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" )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1956
Joined: Fri Oct 07, 2005 07:08 PM
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Tue Sep 28, 2021 07:52 PM
Hola.-

Code (fw): Select all Collapse
     ::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:
Code (fw): Select all Collapse
     browser ::oCnx:tbsucursal

no me funciona el indice primario "id" que estoy haciendo mal?
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Wed Sep 29, 2021 02:30 AM
Code (fw): Select all Collapse
::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
Regards



G. N. Rao.

Hyderabad, India
Posts: 1364
Joined: Wed Jun 21, 2006 12:39 AM
Re: MariaDB - CREATE TABLE | text, int(11), tinyint
Posted: Thu Nov 04, 2021 02:24 PM
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

Continue the discussion