Thread: Series of 10 questions about the use of postgresql, generally.
- Are there free script for CREATE TYPE (native type) or types out there, online, free for commercial use? With function support, too? Can someone reply with a link or a suggestion?
- If I am using the COPY command for input and output around *.csv files, how may I specify internal tuple delimiters of ',', but at the same time also specify an end of line delimeter of ';' ?
- How may I get postgresql to output the create table statement(s) for one or more tables of one database?
- I know that I can use COPY to import or export one database table between it and a *.csv file. Can I use it to do this with multiple TABLES and *.csv files specified in one COPY COMMAND, or not? How may I use COPY, or another default native postgresql function, to export or import create table commands to and from a *.csv file?
- In the absence of OS command line instructions, is there an internal postgresql way, via COPY or another function for example, to backup an entire database, with all its create table statements and all insert statements, and any other associated object, in one hit? Or is this ill advised?
- -How exactly do Intervals work, via themselves and in relation to the other provided native datatypes? What are Intervals used for?
- When setting up communication to remote databases on remote machines, I need to use the OPTIONS() function. It seems to require as its first function parameter, the schema of the table (the second parameter) that it wants to access. Can I supply a null schema, and still be able to reference the remote table, or must I also make use of IMPORT FOREIGN SCHEMA?
- When I am using INHERITS to setup inheritance between two tables, will this mean that all data inserted into the Parent table is automatically updated into the Child table(s), or not?
- What does the VARYING keyword do to an applicable type in a create table statement? CHARACTER VARYING becomes entirely equivalent to VARCHAR. Static, limited types become more dynamic and are unlimited.
- How may I access the log for the details of a normal table, or similar?
I have been going through the free online book LEARNING postgresql book, that has been compiled by Stack Overflow contributors. I have gotten to the point where I have the following series of unanswered questions:
- Are there free script for CREATE TYPE (native type) or types out there, online, free for commercial use? With function support, too? Can someone reply with a link or a suggestion?
- If I am using the COPY command for input and output around *.csv files, how may I specify internal tuple delimiters of ',', but at the same time also specify an end of line delimeter of ';' ?
- How may I get postgresql to output the create table statement(s) for one or more tables of one database?
- I know that I can use COPY to import or export one database table between it and a *.csv file. Can I use it to do this with multiple TABLES and *.csv files specified in one COPY COMMAND, or not? How may I use COPY, or another default native postgresql function, to export or import create table commands to and from a *.csv file?
- In the absence of OS command line instructions, is there an internal postgresql way, via COPY or another function for example, to backup an entire database, with all its create table statements and all insert statements, and any other associated object, in one hit? Or is this ill advised?
- -How exactly do Intervals work, via themselves and in relation to the other provided native datatypes? What are Intervals used for?
- When setting up communication to remote databases on remote machines, I need to use the OPTIONS() function. It seems to require as its first function parameter, the schema of the table (the second parameter) that it wants to access. Can I supply a null schema, and still be able to reference the remote table, or must I also make use of IMPORT FOREIGN SCHEMA?
- When I am using INHERITS to setup inheritance between two tables, will this mean that all data inserted into the Parent table is automatically updated into the Child table(s), or not?
- What does the VARYING keyword do to an applicable type in a create table statement? CHARACTER VARYING becomes entirely equivalent to VARCHAR. Static, limited types become more dynamic and are unlimited.
- How may I access the log for the details of a normal table, or similar?
- Are there free script for CREATE TYPE (native type) or types out there, online, free for commercial use? With function support, too? Can someone reply with a link or a suggestion?
- If I am using the COPY command for input and output around *.csv files, how may I specify internal tuple delimiters of ',', but at the same time also specify an end of line delimeter of ';' ?
- I know that I can use COPY to import or export one database table between it and a *.csv file. Can I use it to do this with multiple TABLES and *.csv files specified in one COPY COMMAND, or not? How may I use COPY, or another default native postgresql function, to export or import create table commands to and from a *.csv file?
- In the absence of OS command line instructions, is there an internal postgresql way, via COPY or another function for example, to backup an entire database, with all its create table statements and all insert statements, and any other associated object, in one hit? Or is this ill advised?
- -How exactly do Intervals work, via themselves and in relation to the other provided native datatypes? What are Intervals used for?
- When setting up communication to remote databases on remote machines, I need to use the OPTIONS() function. It seems to require as its first function parameter, the schema of the table (the second parameter) that it wants to access. Can I supply a null schema, and still be able to reference the remote table, or must I also make use of IMPORT FOREIGN SCHEMA?
- When I am using INHERITS to setup inheritance between two tables, will this mean that all data inserted into the Parent table is automatically updated into the Child table(s), or not?
- What does the VARYING keyword do to an applicable type in a create table statement? CHARACTER VARYING becomes entirely equivalent to VARCHAR. Static, limited types become more dynamic and are unlimited.
- How may I access the log for the details of a normal table, or similar?
On 6/08/21 4:45 pm, A Z wrote: > I have been going through the free online book LEARNING postgresql > book, that has been compiled by Stack Overflow contributors. I have > gotten to the point where I have the following series of unanswered > questions: [...] > > 9. What does the VARYING keyword do to an applicable type in a create > table statement? CHARACTER VARYING becomes entirely equivalent to > VARCHAR. Static, limited types become more dynamic and are unlimited. > I would suggest that you consider using the type 'text' instead. see: https://www.postgresql.org/docs/13/datatype-character.html [...]
- If I am using the COPY command for input and output around *.csv files, how may I specify internal tuple delimiters of ',', but at the same time also specify an end of line delimeter of ';' ?
you cannot to specify end of line delimiter in Postgres
You can specify end of line delimiter in Perl, Python or PHP. It is highly advisable to learn a scripting language or two when working with databases. With all databases, not just Postgres.
- How may I get postgresql to output the create table statement(s) for one or more tables of one database?
????
- I know that I can use COPY to import or export one database table between it and a *.csv file. Can I use it to do this with multiple TABLES and *.csv files specified in one COPY COMMAND, or not? How may I use COPY, or another default native postgresql function, to export or import create table commands to and from a *.csv file?
COPY can be used just for one table in one timeif you want to make DDL command (CREATE TABLE), then you should to run pg_dump -t tablename -a
- In the absence of OS command line instructions, is there an internal postgresql way, via COPY or another function for example, to backup an entire database, with all its create table statements and all insert statements, and any other associated object, in one hit? Or is this ill advised?
pg_dump
- -How exactly do Intervals work, via themselves and in relation to the other provided native datatypes? What are Intervals used for?
Interval is Postgres native type, that helps with work with date operations that are not possible to map to some basic unit. Internally it is a structure with numeric fields - years, months, days, hours, seconds. For example - I can work with a value '3 months', but without knowledge of the beginning, I cannot say how many days this interval has. You can create interval value by constructor function make_interval, or directly from literal, or you can divide two timestamp values.
Interval is a SQL standard data type for adding and subtracting dates. It is supported by a gazillion of other databases:
https://www.ibm.com/docs/en/informix-servers/12.10?topic=types-sql-datetime-interval-data
https://www.mysqltutorial.org/mysql-interval/
https://www.oracletutorial.com/oracle-basics/oracle-interval/
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
The only major database that does not support the interval type is SQL Server. SQL Server has a major problem with SQL standards. It also doesn't support FETCH FIRST <n> ROWS ONLY OFFSET <n> syntax. Of course, this group is not about SQL Server so I'll leave it at that.
-- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com