Re: Microsoft buys GitHub, is this a threat to open-source

2018-06-04 Thread Rich Shepard
On Mon, 4 Jun 2018, Joshua D. Drake wrote: No but it does show why using non open source platforms for open source projects is an inherently bad idea. Joshua, Sourceforge seems to be out of favor, too, so are there any open source platforms that provide services that sourceforge and github

Re: Open Source tool to deploy/promote PostgreSQL DDL

2018-07-10 Thread Rich Shepard
On Tue, 10 Jul 2018, Hustler DBA wrote: A client of mine is looking for an open source tool to deploy and promote PostgreSQL DDL changes through database environments as part of SDLC. What tools (open source) does the community members use? I normally use scripts, but they want something open so

Re: Recomended front ends?

2019-08-07 Thread Rich Shepard
On Wed, 7 Aug 2019, Igor Korot wrote: On top of what already been said - make sure that the product you are about to start working on will have its requirements clear and concise. This is a critical process that needs to be developed in depth. One criterion that will guide your choice of UI is

Re: Recomended front ends?

2019-08-08 Thread Rich Shepard
On Thu, 8 Aug 2019, Stuart McGraw wrote: I would be a little cautious about Django. Specifically IIRC it insists that tables have a single-column primary keys. Stuart, I looked seriously at Django and did not encounter that limitation. However, I did learn that I'm not a web application de

Re: Recomended front ends?

2019-08-08 Thread Rich Shepard
On Thu, 8 Aug 2019, Adrian Klaver wrote: Unfortunately it does not: https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys Given that the issue: https://code.djangoproject.com/ticket/373 is 14 years old does not inspire confidence that it will change anytime soon. Adrian, That's reall

Re: Recomended front ends?

2019-08-08 Thread Rich Shepard
On Thu, 8 Aug 2019, Tim Clarke wrote: We tried Django without any pleasant results. Tim, That's unexpected and too bad. I'd also caution using MS Access, we're desperate to get away from it. Sharing code has challenges and it is horribly aggressive with caching unless you use un-bound forms

Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
I have the need to convert a flat-file Access database to postgres. I've exported the .mdb tables using mdbtools. There's an accompanying metadata PDF with column names and data types for each of the 84 tables, but no description of the tables or column headings. I've asked the agency to provide t

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Adrian Klaver wrote: So you have the tables in Postgres, correct? Adrian, Not yet. I have the schema extracted using mdb-schema. I did something similar with the USDA Nutrient database(with notion of making it a test dataset): https://ndb.nal.usda.gov/ndb/doc/index Th

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Roger De Four wrote: The easy way - just send it to me. The more challenging way requires using several tools like excel or Open Office. Roger, I could post the .mdb on a cloud web site for download; it's 565M uncompressed; the xz-compressed tarball is a mere 42M. When

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Adrian Klaver wrote: Have you looked at: https://www.streamnet.org/wp-content/uploads/2018/06/StreamNetExchangeStandard2018-1.doc Adrian, Not yet, but I will. Didn't see it when I went to the data pages. Thanks, Rich

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Rich Shepard wrote: I could post the .mdb on a cloud web site for download; it's 565M uncompressed; the xz-compressed tarball is a mere 42M. Will post the URL for the tarball Real Soon Now. Here it is for anyone interested: <https://tinyurl.com/yyzuhrcg>. Rich

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Adrian Klaver wrote: Have you looked at: https://www.streamnet.org/wp-content/uploads/2018/06/StreamNetExchangeStandard2018-1.doc Thanks, Adrian. This looks like it has all the information I need. Under which menu did you find this? I had looked in the Data and Resources

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Michael Nolan wrote: It seemed like for every rule I tried there were a handful of exceptions. We wound up just rewriting the app and not trying to export the data from the previous one. Mike, This is not surprising. My interest is in the data, not the application. Much o

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Roger De Four wrote: Rich - This is the ERD for the Access db you posted Thanks, Roger. The exchange format document Adrian found also has an E-R diagram. Much appreciated, Rich

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Adrian Klaver wrote: Here: https://www.streamnet.org/data/downloadable-data/ Link: Data Exchange Standard (DES). Adrian, Then I missed it when I was in that subdirectory. Thanks, Rich

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Rich Shepard wrote: Thanks, Adrian. This looks like it has all the information I need. Adrian, Off the mail list. I'm reading that metadata document and it seems to me that it's not well constructed. Perhaps this is an Access thing[1]; perhaps the DBA'

Re: Converting Access .mdb to postgres

2019-08-14 Thread Rich Shepard
On Wed, 14 Aug 2019, Rich Shepard wrote: Off the mail list. Sorry all. I thought it went to only Adrian. Rich

Re: Variable constants ?

2019-08-15 Thread Rich Shepard
On Thu, 15 Aug 2019, stan wrote: I need to put a few bossiness constants, such as a labor rate multiplier in an application. I am adverse to hard coding these things. The best plan i have come up with so far is to store them in a table, which would have only 1 row, and a column for each needed c

Re: Variable constants ?

2019-08-16 Thread Rich Shepard
On Fri, 16 Aug 2019, Charles Clavadetscher wrote: Another way to keep a history is using a daterange instead of two columns for start and end date. Something like create table labor_rate_mult ( rate real primary_key, validity daterange not null ) Charles, Just out of curio

Re: Variable constants ?

2019-08-16 Thread Rich Shepard
On Fri, 16 Aug 2019, Charles Clavadetscher wrote: That would be a range with an empty upper bound. Let's say that the rate is valid since 2019-08-14 then the range would look like [2019-08-14,) A query to find the current rate would look like: SELECT rate FROM labor_rate_mult WHERE validity @>

Selecting rows having substring in a column

2019-08-29 Thread Rich Shepard
Using postgres-11.1 here. My SQL knowledge needs expanding and my web searches have not found a satisfactory answer. I hope to learn the correct approach here. A table (Fishes) has an attribute column stream_trib with values such as Small Creek trib to Winding River Roaring River

Re: Selecting rows having substring in a column [RESOLVED]

2019-08-29 Thread Rich Shepard
On Thu, 29 Aug 2019, Adrian Klaver wrote: test=# select * from like_test where fld_1 ilike '%Winding River%'; fld_1 Adrian, Aha! I thought of 'like' but forgot about ilike. That's exactly what I need. Thanks very much, Rich

Re: Selecting rows having substring in a column

2019-08-29 Thread Rich Shepard
On Thu, 29 Aug 2019, Gary Cowell wrote: Look at the 'LIKE' function Gary, Yes, I thought of like but didn't think to look for it in the postgres manual. Thank you very much, Rich

Re: Selecting rows having substring in a column [RESOLVED]

2019-08-29 Thread Rich Shepard
On Thu, 29 Aug 2019, Rich Shepard wrote: Aha! I thought of 'like' but forgot about ilike. That's exactly what I need. 'thought' is the wrong word. I should have written that I once knew of like and had forgotten it. Rich

Query using 'LIKE' returns empty set

2019-08-29 Thread Rich Shepard
Next problem is one I've not before encountered. The .sql file used to import data to the fish_counts table has rows such as this one: ('1237796458250','0','17174','Buchanan Creek','Buchanan Creek trib to North Fork Nehalem River','0-3.25','161980','Unknown','Jack or subadult','Peak live & dead

Re: Query using 'LIKE' returns empty set [FIXED]

2019-08-29 Thread Rich Shepard
On Thu, 29 Aug 2019, Rob Sargent wrote: Are you sure that particular file has the search string? Rob, I'm suitably embarrased: that's the wrong file name. I must be seriously under cafinated. The proper file is fish_data.sql so grep and postgres return 1409 instances. My apologies to all, R

Escape parentheses in aggregate function

2019-08-30 Thread Rich Shepard
I want to copy query results to a text file and there's an aggregate function in the SELECT expression. One of the aggregate function's parentheses seems to end the \copy() function and I don't know how best to write the statement. A minimal example: \copy(select count_value, sum(count_value) fro

Re: Escape parentheses in aggregate function

2019-08-30 Thread Rich Shepard
On Fri, 30 Aug 2019, Tom Lane wrote: I think your problem is the line break, not the parentheses. psql knows how to count parens, but it has no concept of letting backslash commands continue across lines. Tom, Interesting. I've adopted separating select statements by their expressions as it m

Re: Escape parentheses in aggregate function

2019-08-30 Thread Rich Shepard
On Fri, 30 Aug 2019, Tom Lane wrote: FWIW, if you're running a current release then there's a reasonable alternative for writing multi-line COPY-from-query commands; see commit log below. Thanks, Tom. I'm running 11.1 and plan to upgrade to 11.5 this weekend. Regards, Rich

Aggregate functions on groups

2019-08-30 Thread Rich Shepard
Tables hold data on fish counts by stream name, species, and (unreported) collection dates. I'm trying to write a query that returns the total number of each species in each stream. The latest attempt is (lines wrapped by alpine; submitted as one line): \copy (select f.stream_tribs, f.count_valu

Re: Aggregate functions on groups [RESOLVED]

2019-08-30 Thread Rich Shepard
On Fri, 30 Aug 2019, John W Higgins wrote: You are grouping by count_value which means that you are asking the system to return a row for each different count_value. John, I didn't realize this. So if you remove the f.count_value from the select statement (not the sum(f.count_value)) - and

Re: Aggregate functions on groups

2019-08-31 Thread Rich Shepard
On Sat, 31 Aug 2019, Morris de Oryx wrote: Your tributaries and fish master tables make sense. If I read your code right, you're grouping by too many columns. I flattened the data into a survey table for this simple example: Morris, I'm still learning about postgres groups. My approach is to

Updating data: confirmation and question

2019-10-26 Thread Rich Shepard
Before my old server died I ran pg_dumpall on the database there and copied that to my new server. The old database was postgresql-10 and the new one is postgresql-11.5. Am I correct that I can run 'pgsql -f .sql' and overwrite the existing databases with the newer data? Checking the database na

Re: Updating data: confirmation and question

2019-10-26 Thread Rich Shepard
On Sat, 26 Oct 2019, Adrian Klaver wrote: That depends on how you ran pg_dumpall. For instance did you use -c?: Adrian, Yes. Always. https://www.postgresql.org/docs/11/sql-alterdatabase.html ALTER DATABASE name RENAME TO new_name Ah, I should have looked. I apologize. Rich

Re: Updating data: confirmation and question

2019-10-26 Thread Rich Shepard
On Sat, 26 Oct 2019, Adrian Klaver wrote: Then the question is, do you really want to overwrite the new database? Adrian, I want to overwrite the old databases with the new .sql file. I _think_ there's only one database that's changed, but overwriting all won't hurt. Regards, Rich

Re: Updating data: confirmation and question

2019-10-26 Thread Rich Shepard
On Sat, 26 Oct 2019, Adrian Klaver wrote: Just me, but to keep this from being a 'famous last words' moment I would backup up the new(11.5) instance before proceeding. Adrian, Okay. That makes good sense. Will do a pg_dumpall on the 11.5 cluster. When I'm actively working on a database I do

RE: Upgrade procedure

2019-11-05 Thread Rich Shepard
On Tue, 5 Nov 2019, Kevin Brannen wrote: The manual or others here are more knowledgeable than I, but I believe that for a "minor" upgrade, you can just swap out the code and restart PG. For major upgrades, the PG server is going to have to come down as the underlying files might be changed/tran

Logging

2019-12-04 Thread Rich Shepard
Running Slackware-14.2/x86_64 and postgresql-11.5. In /var/log/ are these files: -rw-r- 1 postgres wheel 0 Nov 23 04:40 postgresql-11 -rw-r- 1 postgres wheel 723 Nov 23 04:40 postgresql-11.1 -rw-r- 1 postgres wheel 324 Nov 20 04:40 postgresql-11.2.gz -rw-r- 1 postgres wheel 320

Re: Logging [RESOLVED]

2019-12-04 Thread Rich Shepard
On Wed, 4 Dec 2019, Stephen Eilert wrote: Usually, this is done by logrotate or a similar mechanism in your system. You’ll likely find that other logs in your system follow a similar pattern, not just Postgresql. Stephen, Other logs, controlled by logrotate, rotate daily for a maximum of 4 ba

Re: Logging

2019-12-04 Thread Rich Shepard
On Wed, 4 Dec 2019, Adrian Klaver wrote: Take a look at the logging section of postgresql.conf to see if Postgres is handing off to the system and logrotate Adrian, That conf file is in several places (different flavors). I'll check them all. Thanks, Rich

Encoding/collation question

2019-12-11 Thread Rich Shepard
My older databases have LATIN1 encoding and C collation; the newer ones have UTF8 encoding and en_US.UTF-8 collation. A web search taught me that I can change each old database by dumping it and restoring it with the desired encoding and collation types. My question is whether the older types make

Re: Encoding/collation question

2019-12-11 Thread Rich Shepard
On Wed, 11 Dec 2019, Tom Lane wrote: String comparisons in non-C collations tend to be a lot slower than they are in C collation. Whether this makes a noticeable difference to you depends on your workload, but certainly we've seen performance gripes that trace to that. Tom, How interesting.

Counting number of sites with same number of sampling dates

2019-12-11 Thread Rich Shepard
A sampling location table has 28 distinct sites, each site being sampled from 1 to 67 times. I'm trying to obtain the number of sites having 1 sample, 2 samples, ... 67 samples and am not seeing the solution despite several alternative queries. The query, select site_nbr, count(distinct sampdate

Re: Counting number of sites with same number of sampling dates

2019-12-11 Thread Rich Shepard
On Wed, 11 Dec 2019, Michael Lewis wrote: Put what you have in a subquery and group/aggregate again. select sample_count, count( site_nbr ) FROM ( select site_nbr, count(distinct sampdate) AS sample_count from wrb_hg_cong group by site_nbr order by site_nbr ) sub group by sample_count; Michae

Re: Counting number of sites with same number of sampling dates

2019-12-11 Thread Rich Shepard
On Wed, 11 Dec 2019, Ron wrote: The SUM() function? Ron, Interesting. I'll look at this, too. Regards, Rich

Re: Encoding/collation question

2019-12-12 Thread Rich Shepard
On Thu, 12 Dec 2019, Andrew Gierth wrote: Note that it's perfectly fine to use UTF8 encoding and C collation (this has the effect of sorting strings in Unicode codepoint order); this is as fast for comparisons as LATIN1/C is. Andrew, This is really useful insight. I've not thought of the rela

Changing default ../data/ directory

2020-01-04 Thread Rich Shepard
I run Slackware (currently -14.2/x86_64) and postgres-11.5. The data directory has always been located in /var/lib/pgsql//data. This data directory is located in the / partition on a 240G SSD. There's another 2T HDD with a /data partition and I want to both move the current /var/lib/pgsql/data cl

Re: Changing default ../data/ directory

2020-01-04 Thread Rich Shepard
On Sat, 4 Jan 2020, nikhil raj wrote: Step 1-: Stop the postgres services and change the path of the data directory in postgres.conf file. The postgresql.conf.sample notes that the default value of data_directory is taken from -D in the startup command or the PGDATA environment variable. I sup

Re: Changing default ../data/ directory

2020-01-04 Thread Rich Shepard
On Sat, 4 Jan 2020, Adrian Klaver wrote: Not following above: 1) Are you looking for your current postgresql.conf? Yes. More below. https://www.postgresql.org/docs/11/runtime-config-file-locations.html#GUC-DATA-DIRECTORY Thanks, Adrian. Rich

Re: Changing default ../data/ directory

2020-01-04 Thread Rich Shepard
On Sat, 4 Jan 2020, Jeff Janes wrote: PGDATA should work fine if you always start the server directly. But if you sudo or su to another user, they likely won't inherit your environment variables. And if you use some kind of start-up script, they will likely override it. How do you start and stop

Re: Changing default ../data/ directory

2020-01-04 Thread Rich Shepard
On Sat, 4 Jan 2020, George Neuner wrote: Since the new drive is local you can just move the data directory to its new location and link to it from the default (/var) location. No configuration changes needed. George, Huh! It didn't occur to me to make a softlink to the new directory from the

Re: Changing default ../data/ directory

2020-01-04 Thread Rich Shepard
On Sat, 4 Jan 2020, Adrian Klaver wrote: I don't see anything here: https://slackbuilds.org/slackbuilds/14.2/system/postgresql/rc.postgresql.new that changes the conf location, so postgresql.conf should be in the DATADIR: /var/lib/pgsql/$PG_VERSION/data Adrian, How interesting. When I used 'l

Undeliverable: Re: Changing default ../data/ directory (fwd)

2020-01-04 Thread Rich Shepard
I could not find an address for the pgsql-general list owner. Please excuse my posting to the entire list. Today all my messages generate this response: -- Forwarded message -- Date: Sat, 4 Jan 2020 18:21:10 + From: postmas...@outlook.com To: rshep...@appl-ecosys.com Subject:

Pre-version pg_upgrade syntax check

2020-02-10 Thread Rich Shepard
Running Slackware-14.2/x86_64. Current installation is postgres-11.5 and I'm upgrading to postgresql-12.1. Both versions are installed and stopped. If I have correctly read the pg_upgrade manual page this is the command to use (as user postgres) with lines split to fit the message; the command wi

Re: Pre-version pg_upgrade syntax check

2020-02-10 Thread Rich Shepard
On Mon, 10 Feb 2020, Rich Shepard wrote: -B /usr/lib64/postgesql/12/bin/ \ Typo: it should be /usr/lib64/postgresql/12/bin/ Rich

Re: Pre-version pg_upgrade syntax check

2020-02-10 Thread Rich Shepard
On Mon, 10 Feb 2020, Adrian Klaver wrote: I don't know that the port numbers are required. They are not: https://www.postgresql.org/docs/12/pgupgrade.html "Obviously, no one should be accessing the clusters during the upgrade. pg_upgrade defaults to running servers on port 50432 to avoid uninte

Re: Pre-version pg_upgrade syntax check

2020-02-10 Thread Rich Shepard
On Mon, 10 Feb 2020, Rich Shepard wrote: Good advice; I'll do that. Huh! Not what I expected: postgres@salmo:~$ pg_upgrade -c -b /usr/lib64/postgresql/11/bin/ -B /usr/lib64/postgresql/12/bin/ -d /var/lib/pgsql/11/data -D /var/lib/pgsql/12/data/ (All on one line; wrapped by a

Re: Pre-version pg_upgrade syntax check

2020-02-10 Thread Rich Shepard
On Mon, 10 Feb 2020, Adrian Klaver wrote: What it is saying is -b and -d are pointing at binary and data directories that are incompatible. You need to make sure that: /usr/lib64/postgresql/11/bin/ and /var/lib/pgsql/11/data are actually pointing at 11 instances of binaries and data respective

Re: Pre-version pg_upgrade syntax check

2020-02-11 Thread Rich Shepard
On Mon, 10 Feb 2020, Adrian Klaver wrote: So you already have 11 and 12 instances of Postgres running? Adrian, No. Both 11 and 12 are installed; neither is running. I have a cron job that runs pg_dumpall every weekday night. If so why use pg_upgrade? Because I wanted to try it rather than

Re: Pre-version pg_upgrade syntax check

2020-02-11 Thread Rich Shepard
On Tue, 11 Feb 2020, Rich Shepard wrote: So you already have 11 and 12 instances of Postgres running? Adrian, I just started 12.1 and, as user postgres, read last Friday's backup file. All's well. A final question: which conf file do I edit so when I enter 'psql -l'

Re: Pre-version pg_upgrade syntax check [FIXED]

2020-02-11 Thread Rich Shepard
On Tue, 11 Feb 2020, Rich Shepard wrote: A final question: which conf file do I edit so when I enter 'psql -l' (or open a specific database) I don't need to enter my password? I don't recall having to reset this permission with prior upgrades and want to do so now. Ne

Re: Pre-version pg_upgrade syntax check

2020-02-11 Thread Rich Shepard
On Tue, 11 Feb 2020, Adrian Klaver wrote: The above runs the psql client not the server. It is a way of determining what version binaries /usr/lib64/postgresql/11/bin/ actually contains. Adrian, Aha! Running the command taught me a couple of valuable lessons because both 11 and 12 show they'r

Re: Enforcing uniqueness on [real estate/postal] addresses

2020-05-12 Thread Rich Shepard
On Tue, 12 May 2020, Peter Devoy wrote: Is is possible to have two entries which have the same address_identifier_general, street and postcode, but different descriptions? Unfortunately, yes. The data comes from gov't systems to regulate the development/alteration of arbitrary pieces of proper

RE: Enforcing uniqueness on [real estate/postal] addresses

2020-05-13 Thread Rich Shepard
On Wed, 13 May 2020, Basques, Bob (CI-StPaul) wrote: Was wondering if you ever thought about binding the textual address to a USNG location. https://usngcenter.org/ Bobb, et al.: Why not have a 'parent' table with entries such as 'Foo Farm' and a 'child' table with rows for sub-parts of the p

Check for duplicates before inserting new rows

2020-09-04 Thread Rich Shepard
This is a new issue for me: I've received data from a different source and need to add non-duplicates to two tables in the database. Each row in the new data has a station ID and associated measurements. The existing database includes a table for station information and another for measurements m

Re: Check for duplicates before inserting new rows

2020-09-04 Thread Rich Shepard
On Fri, 4 Sep 2020, George Woodring wrote: I would suggest creating a temp table based on the original table and loading the data into it first. You can then purge the duplicates. George, I hadn't thought of this. Using a duplicate table without a PK would work well if there's only one attrib

Re: Check for duplicates before inserting new rows

2020-09-04 Thread Rich Shepard
On Fri, 4 Sep 2020, Olivier Gautherot wrote: First of all, what version of PostgreSQL are you using? Olivier, 12.2. One way would be to add a UNIQUE constraint and perform for each row of the source table a INSERT ... ON CONFLICT DO NOTHING (see https://www.postgresql.org/docs/current/sql-i

Re: Check for duplicates before inserting new rows

2020-09-04 Thread Rich Shepard
On Fri, 4 Sep 2020, Chris Sterritt wrote: Assuming some simple table structures (I've not included PK or FK definitions for simplicity): Chris, Thanks very much. Stay well, Rich

Modifying database schema without losing data

2020-09-28 Thread Rich Shepard
I've been developing a business tracking application for my own use and it's worked well up to now. But, I need to modify it by adding a table with attributes from two other tables. I've not drawn a E-R diagram so I show the two existing tables here: CREATE TABLE Organizations ( org_id serial P

Re: Modifying database schema without losing data

2020-09-28 Thread Rich Shepard
On Mon, 28 Sep 2020, Adrian Klaver wrote: You could use INSERT INTO location(new_fields,) SELECT the_fields FROM the_table(s). Well, duh! I could have thought of that. That's exactly what I'll do: Create the new table, move data from the old table into it, then drop columns in the old table .

Re: Modifying database schema without losing data

2020-09-28 Thread Rich Shepard
On Mon, 28 Sep 2020, Adam Scott wrote: What if a person is a member of more than one Org? Consider a person_org table. Adam, Not applicable. An individual is employed by a single organization. I see mention of a site in the person table. It may also be the case that you need a site table.

Re: Modifying database schema without losing data

2020-09-28 Thread Rich Shepard
On Mon, 28 Sep 2020, Tom Lane wrote: No part-timers in your universe? (My friends in the restaurant business would surely find the above pretty laughable.) Tom, Not in the markets I serve; at least, not at the environmental manager level. I don't work for retail businesses; primarily natural

Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
I'm loading data into tables with the 'insert' statement. There are many rows containing values and each is bracketed by parentheses except for the last row. That's terminated with a semicolon, but psql reports an error there: psql:organizations.sql:1926: ERROR: syntax error at or near ";" LINE

Re: Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Rob Sargent wrote: Can we see the last two line of the file (1924, 1925)? Rob, (2697,'Port of Newport','http://www.portofnewport.com',null,'Port','Opportunity',null), (2698,'Port of Portland','http://www.portofportland.com',null,'Port','Opportunity',null); Each line is

Re: Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Paul Förster wrote: (2698,'Port of Portland','http://www.portofportland.com',null,'Port','Opportunity',null); the last line has a closing parenthesis missing. Paul, I see a closing parenthesis immediately in front of the semi-colon and emacs shows it matches the opening

Re: Multi-row insert: error at terminal row. [RESOLVED]

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Adrian Klaver wrote: Pretty sure the thinking is that the opening parenthesis is further upstream, say around VALUES? Well, duh! Of course. I forgot to enclose all value rows. Mea culpa! Thanks, Rich

Re: Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Paul Förster wrote: insert ... ( (v1, v2, v3), (v4, v5, v6), (v7, v8, v9)<= this is the bracket pair that Emacs shows as matching. ); <= this is the missing bracket. Paul/Adrian/Tom: First thing I did was look at the postgres 12 manual. On page 155 I see:

Re: Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, David G. Johnston wrote: That said seeing the first few rows, in addition to the last few, would help. David, insert into organizations (org_nbr,org_name,org_url,org_email,industry,status,comment) values (1,'Tidewater Contractors Inc',null,null,'Mining','Opportunity','GE

Re: Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, David G. Johnston wrote: As your general syntax seems correct I would suspect an issue in the data values - like having a single quote in an organization name that isn't properly escaped (doubled). I'd first make sure insert one record works then begin bisecting your values,

Re: Multi-row insert: error at terminal row.

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Adrian Klaver wrote: INSERT INTO products (product_no, name, price) VALUES ( (1, 'Cheese', 9.99), (2, 'Bread', 1.99), (3, 'Milk', 2.99) ); then you should have gotten a different error. Something like: ERROR: column "product_no" is of type integer but expressi

Re: Multi-row insert: error at terminal row. [RESOLVED]

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Rich Shepard wrote: psql:organizations.sql:1926: ERROR: syntax error at or near ";" LINE 1925: ...m',null,'Port','Opportunity',null); ^ I'm not seeing why that's an error. A

Re: Multi-row insert: error at terminal row. [RESOLVED]

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Adrian Klaver wrote: Is orgs-1.sql just the INSERT? Yes. How is that file being fed to psql? $ psql -d bustrac -f orgs-1.sql Rich

Re: Multi-row insert: error at terminal row. [RESOLVED]

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Adrian Klaver wrote: Is it just the 50 line version? Adrian, Nope. If it is, what happens if you go back to original 1925 line version and correct the NULL issue in the line 26 and run it again? I'm finding typos and column tranposition errors that I had not spotted w

Re: Multi-row insert: error at terminal row. [RESOLVED]

2020-10-29 Thread Rich Shepard
On Thu, 29 Oct 2020, Rob Sargent wrote: Would it be rude to suggest that you re-visit how that file was made? Seems you'll be in the same boat "next time". Rob, Part of the files was exported from the old version of the database. New rows were from different text files, each with a different

Drop column constraint

2020-10-30 Thread Rich Shepard
A table has a unique constraint on a column that needs removing. Reading the postgres-12.x docs for alter table it appears the correct syntax is: alter table locations drop constraint unique; but this is wrong. Trying 'alter table locations alter column loc_nbr drop constraint unique;' also fai

Re: Drop column constraint [FIXED]

2020-10-30 Thread Rich Shepard
On Fri, 30 Oct 2020, Adrian Klaver wrote: It should be: alter table locations drop constraint 'constraint_name'; Adrian, Yes, I forgot to quote the constraint_name, And, I used the DDL name 'unique' rather than the internal name "locations_loc_nbr_key". Using the latter, and adding 'cascade'

Re: Drop column constraint [FIXED]

2020-10-30 Thread Rich Shepard
On Fri, 30 Oct 2020, Adrian Klaver wrote: Actually unique is not the name, it is the constraint type. You can create your own name when creating the constraint or Postgres will create one for you. Adrian, Got it, thanks. Rich

Another user error?

2020-11-01 Thread Rich Shepard
When trying to populate the locations table I get this error: psql:locations.sql:2105: ERROR: syntax error at or near ";" LINE 2105: ...E Airport Way',null,'Portland','OR','97218',null,null,null); ^ Line 2105 is the last lin

Re: Another user error?

2020-11-01 Thread Rich Shepard
On Sun, 1 Nov 2020, Adrian Klaver wrote: I'm hoping that it is: 'Every line prior to this one is terminated with a comma' not colon. Adrian, That's the case. The only colons are within strings. Thanks, Rich

Re: Another user error?

2020-11-01 Thread Rich Shepard
On Sun, 1 Nov 2020, Rich Shepard wrote: Every line prior to this one is terminated with a colon. All other syntax errors have been corrected. Er, that's comma, not colon. Need to recaffinate. Rich

Re: Another user error?

2020-11-01 Thread Rich Shepard
On Sun, 1 Nov 2020, Francisco Olarte wrote: This is nearly impossible to diagnose without a chunk of the query ( i,e, the first lines and the last ones ). Francisco, $ psql -d bustrac -f locations.sql It smells to missing parentheses. If you use some editor witch matches them, try adding on

Re: Another user error?

2020-11-01 Thread Rich Shepard
On Sun, 1 Nov 2020, Adrian Klaver wrote: Also need the beginning lines including the INSERT part. insert into locations (org_nbr,loc_nbr,loc_name,loc_addr1,loc_addr2,loc_city,state_code,loc_postcode,loc_phone,loc_fax,comment) values (1,1,'2nd Bridge Gravel Bar','16156 Hwy 101 S',null,'Brookin

Re: Another user error? [RESOLVING]

2020-11-01 Thread Rich Shepard
On Sun, 1 Nov 2020, David G. Johnston wrote: You encountered and asked on this exact same issue Friday...the advice in that "Multi-row insert: error at terminal row." all still applies. David J. Which is why I did this file chunk-by-chunk. Re-doing this by portions I find psql reporting erro

Re: Another user error? [RESOLVING]

2020-11-01 Thread Rich Shepard
On Sun, 1 Nov 2020, Peter J. Holzer wrote: Your chunk still seems to be 2105 lines long. Peter, I've started from the top and work in 50-100 line chunks. I'm finding psql errors that it had not flagged the first time through. So I'm working slowly and carfully and expect to find all my typos

PK issue: serial sequence needs updating

2020-11-17 Thread Rich Shepard
Running postgresql-12.2-x86_64-1_SBo on Slackware-14.2/x86_64. My restructed business database has populated tables, but the primary keys are not aware of the current maximum number since the table rows were added external to postgres and read in using psql. For example, I'm trying to add a new

Re: PK issue: serial sequence needs updating [RESOLVED]

2020-11-17 Thread Rich Shepard
On Tue, 17 Nov 2020, Adrian Klaver wrote: https://www.postgresql.org/docs/12/sql-altersequence.html ALTER SEQUENCE people_person_nbr_seq RESTART 485; Thanks, Adrian. I missed that page. Regards, Rich

Re: Alter the column data type of the large data volume table.

2020-12-03 Thread Rich Shepard
On Thu, 3 Dec 2020, Michael Lewis wrote: On Wed, Dec 2, 2020 at 11:53 PM charles meng wrote: I have a table with 1.6 billion records. The data type of the primary key column is incorrectly used as integer. I need to replace the type of the column with bigint. Is there any ideas for this?

Re: Alter the column data type of the large data volume table.

2020-12-03 Thread Rich Shepard
On Thu, 3 Dec 2020, Michael Lewis wrote: Afaik, it will require an access exclusive lock for the entire time it takes to re-write the 1.6 billion rows and update all indexes. That sort of lock out time doesn't seem workable in many production systems. Michael, Okay. I hadn't thought of that.

User input to queries

2020-12-09 Thread Rich Shepard
While I develop the application's GUI I use the database from the command line (psql). While some queries are self-contained others need user input. I've not found a search term that locates this information in the postgres-12 user manual and my web searches suggest that using '&' should work. I

Re: User input to queries

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Michael Lewis wrote: Are you looking for this perhaps? https://www.postgresql.org/docs/current/sql-prepare.html Michael, I don't think so. Reading the PREPARE doc page my understanding is that its use is for statement execution optimization, not asking for user data input

  1   2   3   4   5   6   >