# Database Tables not Created

**URL:** <https://forum.inductiveautomation.com/t/database-tables-not-created/17998>\
**Category:** Ignition\
**Tags:** ignition79, database\
**Created:** [May 11, 2018, 4:19pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998 "2018-05-11T16:19:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [May 11, 2018, 4:19pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/1 "2018-05-11T16:19:47Z")

</div>

I am attempting to configure tag history and database connection after doing a fair amount of development and it seems as though the database tables are not getting created despite having a valid database connection and many tags configured to use the database for history.

Using: Windows Server 2016, SQL Server 2017 Express, Ignition 7.9.7

Looking at the status for the database on the Ignition gateway everything appears to be in order (valid connection) but the total throughput only shows as 0.1 queries/sec.

Looking at the store and forward status on the Ignition gateway I see a regularly increasing quarantine count with reason “Invalid object name ‘sqlth\_drv’”

The error above seems to indicate that it can’t find that database table and looking in SQL management studio it appears as though no tables have been added to the database by ignition.

Any suggestions to resolve this?

## I am seeing these errors repeating in the diagnostics log:

E  
MemoryForwardTransaction Time:  
11May2018 10:06:39  
Message:  
Error forwarding data



Logger:  
W  
TagHistoryDatasourceSink Time:  
11May2018 10:06:32  
Message:  
There is a problem checking the tag history database tables during initialization of the store and forward engine which could prevent tag history data from being forwarded properly. Trying again in 60 seconds.



Logger:  
W  
TagHistoryDatasourceSink Time:  
11May2018 10:06:29  
Message:  
There is a problem checking the tag history database tables during initialization of the store and forward engine which could prevent tag history data from being forwarded properly. Trying again in 60 seconds.



Logger:  
E  
DatasourceForwardTransaction Time:  
11May2018 10:06:21  
Message:  
Error forwarding data



## Logger: E SocketIODelegate Time: 11May2018 10:06:20 Message: Socket connection closed, DriverState was Connected.

Another post suggest that tables are automatically created when an attempt is made to push history to the database but that does not seem to be the case here.  
[http://forum.inductiveautomation.com/t/when-are-db-tables-automatically-created/15089/3](http://forum.inductiveautomation.com/t/when-are-db-tables-automatically-created/15089/3)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 11, 2018, 4:23pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/2 "2018-05-11T16:23:39Z")

</div>

Can you upload the actual wrapper.log or system\_logs.idb file (or PM it to me if you’re not comfortable uploading it?)  
These files are in the ignition install directory, in the `/logs` folder; see [https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/119/0/obtaining-ignition-logs](https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/119/0/obtaining-ignition-logs) for more info.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [May 11, 2018, 4:33pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/3 "2018-05-11T16:33:53Z")

</div>

I have PM’d you the wrapper.log file. The site would not allow me to attache the system\_logs.idb file due to file size.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [May 11, 2018, 4:36pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/4 "2018-05-11T16:36:10Z")

</div>

I see there is a Create table permission denied message logged in there. I’ll confirm but had thought the user used for the connection had ownership of the DB.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 11, 2018, 4:36pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/5 "2018-05-11T16:36:52Z")

</div>

Yep, that’s exactly what the issue is. The system is trying to create the requisite tables but isn’t able to.

---

<div class="post-metadata">

**Author:** ![tyler.bennett](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@tyler.bennett](https://forum.inductiveautomation.com/u/tyler.bennett)\
**Post date:** [May 11, 2018, 4:54pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/6 "2018-05-11T16:54:18Z")

</div>

Thanks for pointing me to the wrapper.log file (very helpful). I was able to identify and correct a permissions issue with the user account used for the database connection. The database tables were then created automatically.

---

<div class="post-metadata">

**Author:** ![manutchaisrichai](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@manutchaisrichai](https://forum.inductiveautomation.com/u/manutchaisrichai)\
**Post date:** [November 21, 2019, 1:40am UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/7 "2019-11-21T01:40:04Z")

</div>

Dear All,  
I’m working with version 8.0.3 right now, I think I have face by the same problem.  
My database connection is valid, and I’m already enable the tag history in the tag pane, but there is no automatic table is created in SQL.

Please inform what is the root cause , and how are you solving this issue.

Best Regard,  
Manutchai S.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 21, 2019, 1:25pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/8 "2019-11-21T13:25:06Z")

</div>

Does the wrapper log have anything to say about it?

---

<div class="post-metadata">

**Author:** ![st300](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@st300](https://forum.inductiveautomation.com/u/st300)\
**Post date:** [December 18, 2019, 8:20am UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/9 "2019-12-18T08:20:48Z")

</div>

Hi all,

I am facing this issue on Ignition 8.0.3. I deleted the sqlt\_data\_x\_x\_x tables by accident while clearing out some old historical tag data that was no longer required.

I have tag historian enabled for a few tags but I get the error

"Exception: Error running query:  
TagHistory(paths=[prov:default:/tag:propulsion (port)/portmelopressure], start=Wed Dec 18 16:18:15 SGT 2019, end=Wed Dec 18 16:19:15 SGT 2019, flags=0)@0ms  
On: Propulsion Overview.Root Container.Group.PME\_Speed 1.Chart Control Command 3.data  
caused by GatewayException: Table ‘smav.sqlt\_data\_3\_2019\_12’ doesn’t exist  
caused by SQLSyntaxErrorException: Table ‘smav.sqlt\_data\_3\_2019\_12’ doesn’t exist  
"  
when I try to display tag history. I found that Ignition has not recreated the sqlt\_data\_x\_x\_x tables in mySQL.

I think there is an issue with Ignition auto creating tables in my database. How can I fix this? I have tried linking my gateway to a fresh mySQL schema but no tables were created either.

---

<div class="post-metadata">

**Author:** ![jeff.jacobs](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jeff.jacobs](https://forum.inductiveautomation.com/u/jeff.jacobs)\
**Post date:** [March 21, 2020, 12:11am UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/10 "2020-03-21T00:11:01Z")

</div>

Based on my testing, it appears that Ignition does not properly handle Postgres treating CREATE TABLE as transnational. I’ve been able to create tables in user: Postgres, schema: public, but not able to create them with a user and schema that I created. I tried SET SCHEMA for the pre-connect script, but that didn’t help.

In creating tables from SQL Workbench, I’ve consistently found that COMMIT is required after CREATE TABLE. I’mnot sure if this is a user issue, or a schema issue or?, but IMO, it’s a bug.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 21, 2020, 12:57am UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/11 "2020-03-21T00:57:39Z")

</div>

> [@jeff.jacobs](#):
>
> but not able to create them with a user and schema that I created.

Did you give that user ownership of or equivalent permissions in the DB containing the schema?

FWIW, I generally use the postgres account to create an empty DB owned by the desired ignition user. Then the ignition user "just works".

> [@jeff.jacobs](#):
>
> that COMMIT is required

I've never run into that, and I use PostgreSQL all the time. Did you have a trailing semicolon on the CREATE statement? Have you searched your workbench preferences for an automatic transaction mode setting? (I usually use psql or the designer's own Query Browser, and have never had this problem.)

What workbench, BTW? The typical PostgreSQL user will be using pgAdmin4.

---

<div class="post-metadata">

**Author:** ![m.stretti](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@m.stretti](https://forum.inductiveautomation.com/u/m.stretti)\
**Post date:** [June 25, 2021, 3:22pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/12 "2021-06-25T15:22:05Z")

</div>

I ran into the same issue:  
I have different schemas in my database and datasources.  
Ignition created historian tables only for the first datasource and not for the others. And historian is throwing errors because the tables are not there.

I worked around it by manually adding the tables in the schemas and adding a trigger that would add the tables partitions whenever ignition adds a line in the “sqlth\_partitions” table…

````auto
CREATE OR ALTER TRIGGER tai_qlt_sqlth_partitions ON SCADA.qlt.sqlth_partitions
AFTER INSERT
AS
BEGIN
DECLARE @tablename NVARCHAR(100)
SET @tablename = (SELECT TOP 1 pname FROM INSERTED )
DECLARE @insert_query NVARCHAR(MAX);
SET @insert_query =CONCAT(N'CREATE TABLE SCADA.qlt.', @tablename,' (
		tagid int NOT NULL,
		intvalue bigint NULL,
		floatvalue float NULL,
		stringvalue nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
		datevalue datetime NULL,
		dataintegrity int NULL,
		t_stamp bigint NOT NULL,
		CONSTRAINT PK __sqlt_dat__', @tablename,' PRIMARY KEY (tagid,t_stamp)
	)
 	CREATE NONCLUSTERED INDEX ', @tablename,'t_stampndx ON qlt.', @tablename,' ( t_stamp ASC )  
	WITH ( PAD_INDEX = OFF ,FILLFACTOR = 100 ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON )
	 ON [PRIMARY] ')
EXEC sp_executesql @insert_query
END```
````
