Giriş
Söz dizimi şöyle
ALTER VIEW view_name AS select_statement;
postgre#\c payment
You are not connected to database 'payment' as "...".
payment#postgres=# \c myjhipsterplanet
You are now connected to database "myjhipsterplanet" as user "mypostgresqldumpplanet".\connect springbootjpa> \c pg_dev
> CREATE TABLE mini_ticker (...);psql -h "$host" -U postgres -d demo
-c "\copy (SELECT row_to_json(t) FROM ( $query ) t) To STDOUT"
>> metrics/query-output.log
\copy admission FROM '/home/data/admit_1.csv' DELIMITER ',' CSV HEADER> CREATE TABLE grades(id SERIAL NOT NULL, g INT NOT NULL);
> CREATE INDEX grades_index ON grades(g);
> \d grades;
Table "public.grades"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+------------------------------------
id | integer | | not null | nextval('grades_id_seq'::regclass)
g | integer | | not null |
Indexes:
"grades_index" btree (g)demodb=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------------------+-------+----------
public | flyway_schema_history | table | postgres
public | tenant | table | postgres
(2 rows)
demodb=# \d tenant
Table "public.tenant"
Column | Type | Collation | Nullable | Default
--------+------------------------+-----------+----------+---------
id | uuid | | not null |
name | character varying(100) | | not null |
Indexes:
"tenant_pkey" PRIMARY KEY, btree (id)# \di+
List of relations
Schema | Name | Type | Owner | Table | Persistence | Access method | Size | Description
--------+-------+-------+----------+-------+-------------+---------------+---------+-------------
public | a_idx | index | postgres | t1 | permanent | btree | 6712 kB |
(1 row)# select pg_relation_filepath('a_idx');
pg_relation_filepath
----------------------
base/16699/16723
(1 row)# show data_directory;
data_directory
-----------------------------------
/home/postgres/pgdata/data
(1 row)# \! ls /home/postgres/pgdata/data/base/16699/16723
/home/postgres/pgdata/data/base/16699/16723adv=> \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------------------+-------+-------
adv | cfr_history_log | table | adv
...partitioning_test=# \dxList of installed extensionsName | Version | Schema | Description--------------------+---------+------------+------------------------------------------------------------------------bloom | 1.0 | public | bloom access method - signature file based indexcitext | 1.6 | public | data type for case-insensitive character stringscitus | 13.1-1 | pg_catalog | Citus distributed databasecitus_columnar | 12.2-1 | pg_catalog | Citus Columnar extensionhstore | 1.8 | public | data type for storing sets of (key, value) pairspg_cron | 1.6 | pg_catalog | Job scheduler for PostgreSQLpg_ivm | 1.11 | pg_catalog | incremental view maintenance on PostgreSQLpg_partman | 5.2.4 | partman | Extension to manage partitioned tables by time or IDpg_stat_statements | 1.11 | public | track planning and execution statistics of all SQL statements executedpg_trgm | 1.6 | public | text similarity measurement and index searching based on trigramspgcrypto | 1.3 | public | cryptographic functionsplpgsql | 1.0 | pg_catalog | PL/pgSQL procedural languagepostgres_fdw | 1.1 | public | foreign-data wrapper for remote PostgreSQL serversuuid-ossp | 1.1 | public | generate universally unique identifiers (UUIDs)vector | 0.8.0 | public | vector data type and ivfflat and hnsw access methods(15 rows)
\i "C:\Users\myname\some path\query.sql"postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------------------+------------------------+----------+------------+------------+---------------------------------------------------
myjhipsterplanet | myjhipsterplanet | UTF8 | en_US.utf8 | en_US.utf8 |
mypostgresqldumpplanet | mypostgresqldumpplanet | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | mypostgresqldumpplanet | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | mypostgresqldumpplanet | UTF8 | en_US.utf8 | en_US.utf8 | =c/mypostgresqldumpplanet +
| | | | | mypostgresqldumpplanet=CTc/mypostgresqldumpplanet
template1 | mypostgresqldumpplanet | UTF8 | en_US.utf8 | en_US.utf8 | =c/mypostgresqldumpplanet +
| | | | | mypostgresqldumpplanet=CTc/mypostgresqldumpplanetCREATE PROCEDURE insert_address_data(recs INTEGER)
LANGUAGE plpgsql AS
$$
DECLARE
address_id VARCHAR;
address_city VARCHAR;
address_state VARCHAR;
BEGIN
for i in 1..recs LOOP
SELECT CONCAT('id0000-1234545-98756453-00' ,i) INTO address_id;
SELECT CONCAT('city_' ,i) INTO address_city;
SELECT CONCAT('state_' ,i) INTO address_state;
INSERT INTO address (id, city, state) VALUES (address_id, address_city, address_state);
IF i % 10000 = 0 THEN
COMMIT;
END IF;
END LOOP;
END
$$;
--
-- INSERT 100K records in each table. Record the time from pgAdmin
CALL insert_books_data(100000);
CALL insert_employees_data(100000);
CALL insert_employees_data(100000);<dependency><groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.5.4</version> </dependency>