MariaDB - CREATE TABLE | text, int(11), tinyint

MariaDB - CREATE TABLE | text, int(11), tinyint

Postby Otto » Tue Nov 27, 2018 6: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: MariaDB - CREATE TABLE | text, int(11), tinyint

Postby Otto » 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 )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: MariaDB - CREATE TABLE | text, int(11), tinyint

Postby nageswaragunupudi » Wed Nov 28, 2018 10:18 am

Code: Select all  Expand view  RUN
  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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MariaDB - CREATE TABLE | text, int(11), tinyint

Postby goosfancito » Tue Sep 28, 2021 7:52 pm

Hola.-

Code: Select all  Expand view  RUN
    ::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: Select all  Expand view  RUN
    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/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: MariaDB - CREATE TABLE | text, int(11), tinyint

Postby nageswaragunupudi » Wed Sep 29, 2021 2:30 am

Code: Select all  Expand view  RUN

::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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MariaDB - CREATE TABLE | text, int(11), tinyint

Postby horacio » Thu Nov 04, 2021 2: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
horacio
 
Posts: 1363
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests