| From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
|---|---|
| To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Definging columns for INSERT statements |
| Date: | 2024-06-12 23:05:21 |
| Message-ID: | 92fdd56a-9600-42d6-bee7-5f071f0f0f09@aklaver.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 6/12/24 14:11, Rich Shepard wrote:
> I have > 100 rows to add to a table using INSERT INTO statements. I want
> the
> PK to be the next value in the sequence. Would this be the appropriate
> syntax for the columns to be entered?
>
> INSERT INTO people (person_nbr
> DEFAULT('people_person_nbr_seq'),lname,fname,job_title DEFAULT
> 'Contact',company_nbr,loc_nbr,direct_phone,cell_phone,email,active
> DEFAULT('true')) VALUES
> ( ...
Assuming 'people_person_nbr_seq' is the sequence attached to person_nbr
and the other DEFAULTs are the column defaults then the syntax would be:
INSERT INTO people
(person_nbr, lname, fname, job_title, company_nbr,loc_nbr, direct_phone,
cell_phone,email, active)
VALUES
(DEFAULT, 'klaver', 'adrian', DEFAULT, 1, 1, '555-1234', '555-4321',
'adrian(dot)klaver(at)aklaver(dot)com', DEFAULT);
If they are not the column defaults then just supply the literal value.
>
> TIA,
>
> Rich
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2024-06-12 23:07:36 | Re: PG16.1 security breach? |
| Previous Message | Tom Lane | 2024-06-12 22:56:54 | Re: PG16.1 security breach? |