ExecuteSQLCreateTable: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
===Returns=== | ===Returns=== | ||
The function doesn't return anything. | The function doesn't return anything. | ||
==Example== | |||
<syntaxhighlight lang="lua"> | |||
function onMapLoad () | |||
-- create our table, if it doesn't already exist | |||
executeSQLCreateTable ( "players", "clothes_head_texture TEXT, clothes_head_model TEXT, player TEXT" ) | |||
end | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Registry_functions}} | {{Registry_functions}} |
Revision as of 15:24, 23 September 2006
This function creates a table in the database. It doesn't do anything when the table already exists. You can use this function in the loading or initialisation step of your script to ensure all the necessary tables that you use actually exist.
The executed SQL query is the following:
[sql]CREATE TABLE IF NOT EXISTS <table> ( <definition> )
Syntax
nil executeSQLCreateTable ( string table, string definition )
Required Arguments
- table: The name of the table you want to create.
- definition: The definition of the table, this includes the column definitions and constraints in SQL syntax. For each column definition, you start with the name (without any spaces), optionally followed by the SQL data type and constraint (all separated by spaces). Each column definition is separated by a comma (,) (e.g. field1,field2,field3 or field1 INTEGER,field2 TEXT as definition). Please refer to the SQLite SQL documentation for more information on creating even more complex tables.
Returns
The function doesn't return anything.
Example
function onMapLoad () -- create our table, if it doesn't already exist executeSQLCreateTable ( "players", "clothes_head_texture TEXT, clothes_head_model TEXT, player TEXT" ) end
See Also