﻿---
sidebar_position: 2
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Create table
 Creates an empty table in the database



`Function CreateTable(Val Table, Val ColoumnsStruct, Val Connection = "") Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Table | --table | String | &#x2714; | Table name |
  | ColoumnsStruct | --cols | Structure Of KeyAndValue | &#x2714; | Column structure: Key > Name, Value > Data type |
  | Connection | --db | String, Arbitrary | &#x2716; | Existing connection or database path |

  
  Returns:  Map Of KeyAndValue - Result of query execution

<br/>




```bsl title="1C:Enterprise/OneScript code example"
    Base  = "C:\Users\Administrator\AppData\Local\Temp\v8_436F_151.sqlite";
    Table = "test";

    ColoumnsStruct = New Structure;
    ColoumnsStruct.Insert("id"        , "INTEGER PRIMARY KEY");
    ColoumnsStruct.Insert("name"      , "TEXT");
    ColoumnsStruct.Insert("age"       , "INTEGER");
    ColoumnsStruct.Insert("salary"    , "REAL");
    ColoumnsStruct.Insert("is_active" , "BOOLEAN");
    ColoumnsStruct.Insert("created_at", "DATETIME");
    ColoumnsStruct.Insert("data"      , "BLOB");

    Result = OPI_SQLite.CreateTable(Table, ColoumnsStruct, Base);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint sqlite CreateTable \
             --table "test" \
             --cols "{'id':'INTEGER PRIMARY KEY','name':'TEXT','age':'INTEGER','salary':'REAL','is_active':'BOOLEAN','created_at':'DATETIME','data':'BLOB'}" \
             --db "C:\Users\Administrator\AppData\Local\Temp\5dsztk433re.sqlite"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: JSON data can also be passed as a path to a .json file
            
            oint sqlite CreateTable ^
             --table "test" ^
             --cols "{'id':'INTEGER PRIMARY KEY','name':'TEXT','age':'INTEGER','salary':'REAL','is_active':'BOOLEAN','created_at':'DATETIME','data':'BLOB'}" ^
             --db "C:\Users\Administrator\AppData\Local\Temp\5dsztk433re.sqlite"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "result": true
}
```
