Is it possible to empty insert into a table?

Considering there are no table created at the moment
Can I in following statements are possible?

First Call to the Database :                                                     command :create table-with column names and add a single Row. This would create table with the column names and adds a single row in the table

Second Call to the Database : (same operation as previous)command :create table-with column names and add a single Row .This would ignore the create table with column name operation as table is already there. Just adds another row to the table. Now the table has two rows.

Can anyone help here? Is there any example which can be of help?

If you’re talking about in-memory tables then upsert  does this:

q)mytab upsert (col1:ab;col2:1 2);q)mytab upsert ([]col1:cd;col2:3 4);

First commad will create table if it doesn’t exist, second (same command) will append. 

Terry

Thanks @Terry you are a life saver! Why is all these nuances not documented well in KDB?

@Terry this works but I cannot insert only 1 row. With the command I have to insert atleast 2 rows

Hey Ronn, as Charlie explained on your other thread, it’s likely because the columns of your single-row table must be lists, not atoms.

/enlist each element and then flipq)flip col1col2!(enlista;enlist 1)col1 col2---------a 1/or enlist the dictionary of atomsq)enlist col1col2!(a;1)col1 col2---------a 1/single-row strings should be enlistedq)flipcol1col2!(a;enlist"abc")col1 col2----------a “abc”`

Terry

qBitcoin libraries to play with for kdb friends at:

<o:p> </o:p>

https://github.com/sandybradley<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

<o:p> </o:p>

From: TerryLynch
Sent: Friday, 25 October 2019 17:17
To: Kdb+ Personal Developers
Subject: [personal kdb+] Re: Is it possible to empty insert into a table?

<o:p> </o:p>

Hey Ronn, as Charlie explained on your other thread, it’s likely because the columns of your single-row table must be lists, not atoms.

<o:p> </o:p>

/enlist each element and then flip<o:p></o:p>

q)flip col1col2!(enlist`a;enlist 1)<o:p></o:p>

col1 col2<o:p></o:p>

---------<o:p></o:p>

a    1<o:p></o:p>

/or enlist the dictionary of atoms<o:p></o:p>

q)enlist col1col2!(`a;1)<o:p></o:p>

col1 col2<o:p></o:p>

---------<o:p></o:p>

a    1<o:p></o:p>

<o:p> </o:p>

/single-row strings should be enlisted<o:p></o:p>

q)flipcol1col2!(`a;enlist"abc")<o:p></o:p>

col1 col2<o:p></o:p>

----------<o:p></o:p>

a    “abc”<o:p></o:p>

<o:p> </o:p>

Terry