quiz

Full-stack dev quiz question #64

Full-stack dev quiz question #64quiz

Liquibase has a way to easily import data from to file to a database table. Did you know that? Check sixty fourth question of full-stack dev quiz to verify if you know how to use it.

Liquibase is widely used to manage database structure. But it can manipulate data as well. One of the ways to do that is the loadData change, that imports data from a file to a database table. This time, I have a question for you related to that change.

For the sake of this question, we have an empty table, created by this change set:

<changeSet id="Create table USERS" author="DBA presents">
<createTable tableName="USERS">
<column name="US_ID" type="int" autoIncrement="true">
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_USERS" />
</column>
<column name="US_CREATION_DATE" type="datetime" />
<column name="US_NAME" type="varchar(100)" />
<column name="US_ACTIVE" type="char(1)" defaultValue="A">
<constraints nullable="false" />
</column>
</createTable>
</changeSet>

Here is a Liquibase change set to load data:

<changeSet id="Load data from CSV file" author="DBA presents">
<loadData tableName="USERS" file="data.csv">
<column name="US_CREATION_DATE" header="creationDate" />
<column name="US_NAME" header="name" />
</loadData>
</changeSet>

You can find different file contents. Which options will cause correctly inserting 3 rows to the USERS table?

Choose all valid answers.

  1. 2023-03-21 15:23:00|user1
    2023-03-21 15:23:00|user2
    2023-03-21 15:23:00|us,er3
  2. creationDate,name
    2023-03-21 15:23:00,user1
    2023-03-21 15:23:00,user2
    2023-03-21 15:23:00,user3
  3. creationDate|name
    2023-03-21 15:23:00|user1
    2023-03-21 15:23:00|user2
    2023-03-21 15:23:00|us,er3
  4. creationDate,name
    2023-03-21 15:23:00,user1
    2023-03-21 15:23:00,user2
    2023-03-21 15:23:00,"us,er3"
  5. creationDate|name
    2023-03-21 15:23:00|user1
    2023-03-21 15:23:00|user2
    2023-03-21 15:23:00|"us,er3"

For the correct answer scroll down

.

.

 

 

 

 

 

 

 

 

 

 

Do not miss valuable content. You will receive a monthly summary email. You can unsubscribe anytime.

 

 

 

 

 

 

 

 

 

 

 

 

 

.

.

.

The correct answer is: c, e. If you would like to read more, check Load data from CSV file with Liquibase article.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.