public inbox for [email protected]  
help / color / mirror / Atom feed
"there is no way to insert less than one row"
5+ messages / 4 participants
[nested] [flat]

* "there is no way to insert less than one row"
@ 2021-03-20 19:16 PG Doc comments form <[email protected]>
  2021-03-24 20:09 ` Re: "there is no way to insert less than one row" Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: PG Doc comments form @ 2021-03-20 19:16 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/13/dml-insert.html
Description:

The documentation here says the following: "Of course you can also insert
more than one row, but there is no way to insert less than one row."
I tried this in psql:
---cut---
mydb=> create temporary table t1 (i1 int, v2 varchar(100));
CREATE TABLE
mydb=> create temporary table t2 (i1 int, v2 varchar(100));
CREATE TABLE
mydb=> insert into t2 select * from t1;
INSERT 0 0
mydb=> 
---cut---
So, the last insert command inserted zero rows. What is meant by "there is
no way to insert less than one row"?


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: "there is no way to insert less than one row"
  2021-03-20 19:16 "there is no way to insert less than one row" PG Doc comments form <[email protected]>
@ 2021-03-24 20:09 ` Peter Eisentraut <[email protected]>
  2021-03-24 23:18   ` Re: "there is no way to insert less than one row" David G. Johnston <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Peter Eisentraut @ 2021-03-24 20:09 UTC (permalink / raw)
  To: [email protected]; [email protected]

On 20.03.21 20:16, PG Doc comments form wrote:
> So, the last insert command inserted zero rows. What is meant by "there is
> no way to insert less than one row"?

I think the point was that you can't insert partial rows.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: "there is no way to insert less than one row"
  2021-03-20 19:16 "there is no way to insert less than one row" PG Doc comments form <[email protected]>
  2021-03-24 20:09 ` Re: "there is no way to insert less than one row" Peter Eisentraut <[email protected]>
@ 2021-03-24 23:18   ` David G. Johnston <[email protected]>
  2021-03-24 23:55     ` Re: "there is no way to insert less than one row" Alvaro Herrera <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: David G. Johnston @ 2021-03-24 23:18 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; +Cc: [email protected]; Pg Docs <[email protected]>

On Wed, Mar 24, 2021 at 1:29 PM Peter Eisentraut <
[email protected]> wrote:

> On 20.03.21 20:16, PG Doc comments form wrote:
> > So, the last insert command inserted zero rows. What is meant by "there
> is
> > no way to insert less than one row"?
>
> I think the point was that you can't insert partial rows.
>

Sure, if you think its related to the following sentence.  If you think its
related to the subsequent one it means "cannot insert zero rows".  Frankly,
both interpretations are wrong, inserting an explicit column list with
omitted columns populated using defaults is a "partial row API" for
inserting data.

I'm also not fond of the word "conceptually" here - its actually a physical
reality that regardless of how one or more rows are supplied they are
inserted one-at-a-time so far as constraints, discussed in the previous
chapter, are concerned (though some constraints can be deferred).

David J.


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: "there is no way to insert less than one row"
  2021-03-20 19:16 "there is no way to insert less than one row" PG Doc comments form <[email protected]>
  2021-03-24 20:09 ` Re: "there is no way to insert less than one row" Peter Eisentraut <[email protected]>
  2021-03-24 23:18   ` Re: "there is no way to insert less than one row" David G. Johnston <[email protected]>
@ 2021-03-24 23:55     ` Alvaro Herrera <[email protected]>
  2021-04-07 11:54       ` Re: "there is no way to insert less than one row" Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Alvaro Herrera @ 2021-03-24 23:55 UTC (permalink / raw)
  To: David G. Johnston <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; [email protected]; Pg Docs <[email protected]>

On 2021-Mar-24, David G. Johnston wrote:

> On Wed, Mar 24, 2021 at 1:29 PM Peter Eisentraut <
> [email protected]> wrote:
> 
> > On 20.03.21 20:16, PG Doc comments form wrote:
> > > So, the last insert command inserted zero rows. What is meant by "there
> > is
> > > no way to insert less than one row"?
> >
> > I think the point was that you can't insert partial rows.
> 
> Sure, if you think its related to the following sentence.  If you think its
> related to the subsequent one it means "cannot insert zero rows".  Frankly,
> both interpretations are wrong, inserting an explicit column list with
> omitted columns populated using defaults is a "partial row API" for
> inserting data.

Not really -- what you're doing in that case is insert a row that has
some null columns.  It is still a complete row.  I'm with Peter: the
idea being conveyed is that in tables, rows are atomic units.

> I'm also not fond of the word "conceptually" here - its actually a physical
> reality that regardless of how one or more rows are supplied they are
> inserted one-at-a-time so far as constraints, discussed in the previous
> chapter, are concerned (though some constraints can be deferred).

That doesn't seem a very interesting distinction, but I agree that this
can be worded differently to convey the idea of rows being the basic
units more clearly.  Maybe something like this:

: When a table is created, it contains no data. The first thing to do
: before a database can be of much use is to insert data. Data is
: inserted one row at a time. Of course you can also insert
: more than one row in a single command, but it is not possible to
: insert something that is not a complete row.
: Even if you know only some column values, a complete row is created.

The next paragraphs explain that omitted columns are defaulted, which
IMO flows neatly from here.


(I would substitute "Of course you can also" with "It is possible to" ...
though that results in repetition of the word "possible" ... hmm.)

-- 
Álvaro Herrera                            39°49'30"S 73°17'W





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: "there is no way to insert less than one row"
  2021-03-20 19:16 "there is no way to insert less than one row" PG Doc comments form <[email protected]>
  2021-03-24 20:09 ` Re: "there is no way to insert less than one row" Peter Eisentraut <[email protected]>
  2021-03-24 23:18   ` Re: "there is no way to insert less than one row" David G. Johnston <[email protected]>
  2021-03-24 23:55     ` Re: "there is no way to insert less than one row" Alvaro Herrera <[email protected]>
@ 2021-04-07 11:54       ` Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Peter Eisentraut @ 2021-04-07 11:54 UTC (permalink / raw)
  To: Alvaro Herrera <[email protected]>; David G. Johnston <[email protected]>; +Cc: [email protected]; Pg Docs <[email protected]>

On 25.03.21 00:55, Alvaro Herrera wrote:
> : When a table is created, it contains no data. The first thing to do
> : before a database can be of much use is to insert data. Data is
> : inserted one row at a time. Of course you can also insert
> : more than one row in a single command, but it is not possible to
> : insert something that is not a complete row.
> : Even if you know only some column values, a complete row is created.
> 
> The next paragraphs explain that omitted columns are defaulted, which
> IMO flows neatly from here.

done that way






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-04-07 11:54 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 19:16 "there is no way to insert less than one row" PG Doc comments form <[email protected]>
2021-03-24 20:09 ` Peter Eisentraut <[email protected]>
2021-03-24 23:18   ` David G. Johnston <[email protected]>
2021-03-24 23:55     ` Alvaro Herrera <[email protected]>
2021-04-07 11:54       ` Peter Eisentraut <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox