Home > comp > gb.db.mysql > _table > add 
  [3.0]
 fr de es it nl pl pt pt_BR mk sq ca ar fa vi ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Refresh  Search  Administration  
Documentation
History
 
Add
Creates a table into the current database.

Table: Is the table name.
Engine: Is the storage engine to use.
Charset: Is the charset to use.

If Charset and Engine are not provided, then the default ones are used.

Note that to create a table, you have had to provide some fields information, as well as, index, primary key, etc.

See this page for information about fields.
See this page for supported storage engines.
See this page for supported charsets.
See this example.

Examples

Dim hCon As New Connection

With hCon
  .Type = "mysql"
  .Port = "3306"
  .Host = "localhost"
  .User = "root"
  .Password = "mypass"
  .Name = "Gambas"
  .Open()
End With

hCon.MySQL.Field.Add("actor_id", hCon.MySQL.DataTypes.UnsignedSmallInt, False,, True)
hCon.MySQL.Field.Add("first_name", hCon.MySQL.DataTypes.VarChar(45), False)
hCon.MySQL.Field.Add("last_name", hCon.MySQL.DataTypes.VarChar(45), False)
hCon.MySQL.Field.Add("last_update", hCon.MySQL.DataTypes.TimeStamp, False, "CURRENT_TIMESTAMP",, "CURRENT_TIMESTAMP")
hCon.MySQL.Field.PrimaryKey(["actor_id"])
hCon.MySQL.Field.Index("idx_actor_last_name", "last_name")
hCon.MySQL.Table.Add("actor", "InnoDB", hCon.MySQL.Charset)

MySQL statement:
' Create TABLE `actor` (
'   `actor_id` smallint(5) unsigned NOT NULL auto_increment,
'   `first_name` varchar(45) NOT NULL,
'   `last_name` varchar(45) NOT NULL,
'   `last_update` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
'   PRIMARY KEY(`actor_id`),
'   KEY `idx_actor_last_name` (`last_name`)
' )ENGINE = InnoDB Default CHARSET = utf8