Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb6b49c8

Browse files
Made init.sql for demo db compliant to the styleguide by converting it to lowercase
1 parent814ec65 commitb6b49c8

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

‎config/target-db/init.sql‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
-- Initialize target database for monitoring
22
-- Enable pg_stat_statements extension for query monitoring
3-
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
3+
create extension if not exists pg_stat_statements;
44

55
-- Create a sample table for demonstration
6-
CREATETABLEIF NOT EXISTS sample_data (
7-
idSERIALPRIMARY KEY,
8-
nameVARCHAR(100),
9-
created_atTIMESTAMP DEFAULTCURRENT_TIMESTAMP
6+
createtableif not exists sample_data (
7+
idserialprimary key,
8+
namevarchar(100),
9+
created_attimestamp defaultcurrent_timestamp
1010
);
1111

1212
-- Insert some sample data
13-
INSERT INTO sample_data (name)VALUES
13+
insert into sample_data (name)values
1414
('Sample Record 1'),
1515
('Sample Record 2'),
1616
('Sample Record 3');
1717

1818
-- Create a user for PGWatch monitoring
19-
CREATEUSERmonitorWITH PASSWORD'monitor_pass';
20-
GRANT CONNECTON DATABASE target_databaseTO monitor;
21-
GRANT USAGEON SCHEMA publicTO monitor;
19+
createusermonitorwith password'monitor_pass';
20+
grant connecton database target_databaseto monitor;
21+
grant usageon schema publicto monitor;
2222

2323
-- Create a public view for pg_statistic access
24-
CREATE OR REPLACEVIEWpublic.pg_statisticAS
25-
SELECT
24+
create or replaceviewpublic.pg_statisticas
25+
select
2626
n.nspnameas schemaname,
2727
c.relnameas tablename,
2828
a.attname,
2929
s.stanullfracas null_frac,
3030
s.stawidthas avg_width,
3131
falseas inherited
32-
FROM pg_statistic s
33-
JOIN pg_class cONc.oid=s.starelid
34-
JOIN pg_namespace nONn.oid=c.relnamespace
35-
JOIN pg_attribute aONa.attrelid=s.starelidANDa.attnum=s.staattnum
36-
WHEREa.attnum>0AND NOTa.attisdropped;
32+
from pg_statistic s
33+
join pg_class conc.oid=s.starelid
34+
join pg_namespace nonn.oid=c.relnamespace
35+
join pg_attribute aona.attrelid=s.starelidanda.attnum=s.staattnum
36+
wherea.attnum>0and nota.attisdropped;
3737

3838
-- Grant specific access instead of all tables
39-
GRANTSELECTONpublic.pg_statisticTO pg_monitor;
39+
grantselectonpublic.pg_statisticto pg_monitor;
4040

4141
-- Grant access to monitoring views
42-
GRANTSELECTON pg_stat_statementsTO monitor;
43-
GRANTSELECTON pg_stat_databaseTO monitor;
44-
GRANTSELECTON pg_stat_user_tablesTO monitor;
42+
grantselecton pg_stat_statementsto monitor;
43+
grantselecton pg_stat_databaseto monitor;
44+
grantselecton pg_stat_user_tablesto monitor;
4545
-- Grant pg_monitor role to monitor user for enhanced monitoring capabilities
46-
GRANT pg_monitorTO monitor;
47-
GRANT EXECUTEON FUNCTION pg_stat_file(text)TO monitor;
48-
GRANT EXECUTEON FUNCTION pg_stat_file(text,boolean)TO monitor;
49-
GRANT EXECUTEON FUNCTION pg_ls_dir(text)TO monitor;
50-
GRANT EXECUTEON FUNCTION pg_ls_dir(text,boolean,boolean)TO monitor;
46+
grant pg_monitorto monitor;
47+
grant executeon function pg_stat_file(text)to monitor;
48+
grant executeon function pg_stat_file(text,boolean)to monitor;
49+
grant executeon function pg_ls_dir(text)to monitor;
50+
grant executeon function pg_ls_dir(text,boolean,boolean)to monitor;
5151
-- Set search path for the monitor user
52-
ALTERUSER monitorSET search_path="$user", public, pg_catalog;
52+
alteruser monitorset search_path="$user", public, pg_catalog;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp