Talend tCreateTable component is useful to create a table in a database. We can use this Talend tCreateTable to create a table before loading the output into the database.
In this Talend example, we create a job that loads data into this newly created SQL Server table.
Talend Create Database Table Example
Drag and drop the Talend tCreateTable from palette to job designer.
From the below screenshot, you can see by default it is pointing to the MySQL database. This Talend Component tab has all the properties required to connect with the MySQL database and create a table.
Let me select the MS SQL Server as the Database type.
Now, you can see the options to connect with SQL Server.
We just copied the tFilterRow job and pasted all the components into this job. I suggest you refer to Talend tFilterRow article in Talend.
Next, we removed the OnSubjectOk trigger, and pointed it to tCreateTable and connected the Main row of tCreateTable with tDBInput. It means that once the connection established to the database, it will reach the tCreateTable, and then go to the tDBInput.
Within the Talend tCreateTable Component tab, we use the existing connection and then create a table name a1234. Here, the table action options are the same as the tDBOutput. So, please refer to Load data from the text file to the database article. We are selecting the Drop table if it exists and create, which means it will drop the table if a1234 exists; otherwise, it creates a1234 table.
Please click on the Edit Schema button to create a schema or column name for the table you want to create. As you can see from the below, we create a schema that matches the Customer table that we selected in the tDBInput.
Within the tDBOutput, we changed the table name as a1234, and Action on the table as Truncate Table.
Let me run this Talend Create database table job.
From the below Management Studio screenshot, our job has created the table and stored the filtered data inside it. Within the SQL table properties, you can check the created date and time also.