Create a table
Tutorial for creating a table using the JSON DB API
Complete the tutorial setup.
Both the following create table procedures create a table named "athlete"
. You can use either one.
Note
This procedure must succeed or all other subsequent steps in the tutorial will fail.
Create a table using API Explorer's built-in example
Select the DB API from the Select API dropdown menu.
Select the
"createTable - athlete"
example from the Templates dropdown menu.Click Send request ().
Verify the action completed successfully.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
Create a table using code in this tutorial
Paste this code into the API Request editor.
{ "api": "db", "action": "createTable", "params": { "databaseName": "ctreeSQL", "tableName": "athlete", "fields": [ { "name": "name", "type": "varchar", "length": 30 }, { "name": "ranking", "type": "smallint", "nullable": false }, { "name": "birthDate", "type": "date" }, { "name": "playerNumber", "type": "number", "length": 32, "scale": 6 }, { "name": "livedPast2000", "type": "bit" }, { "name": "earnings", "type": "money", "length": 32, "scale": 4 }, { "name": "favoriteSaying", "type": "varchar", "length": 500 } ] }, "authToken": "clickApplyDefaultsToReplaceThisWithValidAuthToken" }
Click Apply defaults to JSON request () to apply defaults and set the
"authToken"
to a valid value.Note
You will receive this error if you do not click Apply defaults to JSON request () to set the
"authToken"
to a valid session."errorCode": 60031, "errorMessage": "Not possible to find valid session for the provided token." }
Click Send request ().
Verify the action completed successfully.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.