practical-sql icon indicating copy to clipboard operation
practical-sql copied to clipboard

Inclusion of COPY statements in DDL files prevents readers from simply loading them.

Open jberkus opened this issue 8 years ago • 3 comments

Hey, your tech reviewer here.

Example: https://github.com/anthonydb/practical-sql/blob/master/Chapter_08/Chapter_08.sql

The COPY statements are interspersed with table definition statements. The problem with this is that the COPY statements are going to be specific the the reader's OS and where they saved the files. This prevents the reader from simply running the file using PSQL or pgAdmin.

I suggest instead putting the example COPY statements in there, commented out.

jberkus avatar Jun 13 '17 21:06 jberkus

Hey, Josh! 👋

So, you're saying to comment out all the COPY statements in these .sql files so that a reader could create all the tables at once by running the whole script? In that case, do you recommend separating the CREATE TABLE statements from the SELECT statement listings also in the file?

anthonydb avatar Jun 13 '17 22:06 anthonydb

Yeah, I was just realizing that all of the select queries are in one file, which really doesn't work with the "run the file" idea.

Chapter 8 is a little different just because those "create table" statements are so large that they're kind of annoying to copy & paste, or to select+execute in pgAdmin. Specifically for chapter 8, it might do to have a separate file for create table just so that the reader can simply execute those, and all the other statements in another file.

jberkus avatar Jun 14 '17 04:06 jberkus

OK, that sounds like a good idea. I'll switch that up when I revise the chapter based on your additional comments. Thanks!

anthonydb avatar Jun 14 '17 12:06 anthonydb