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

Commite57c92e

Browse files
Step 6. Create DB-view
1 parent44db0d3 commite57c92e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎generate-entities-from-db/blog/SCRIPTS.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,21 @@ ALTER TABLE comments_posts
7474
ADD CONSTRAINT fk_compos_on_post FOREIGN KEY (posts_id) REFERENCES posts (id);
7575

7676
\q
77-
```
77+
```
78+
79+
##Создание DB-view
80+
81+
```bash
82+
psql postgresql://root:root@localhost:5432/blog
83+
84+
CREATE VIEW USER_STATISTICS (USER_ID, NUMBER_OF_POSTS) AS
85+
SELECT
86+
U.ID AS USER_ID,
87+
COUNT(P.ID) AS NUMBER_OF_POSTS
88+
FROM
89+
USERS U
90+
JOIN POSTS P ON U.ID = P.AUTHOR_ID
91+
GROUP BY
92+
U.ID;
93+
\q
94+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp