![]() ![]() However, you can create a view named customer_master as follows: CREATE VIEW customer_master AS The result of the query is as shown in the screenshot below: INNER JOIN country USING (country_id) Code language: SQL (Structured Query Language) ( sql ) If you want to get complete customers data, you normally construct a join statement as follows: SELECT cu.customer_id AS id,Ĭu.first_name || ' ' || cu.last_name AS name,ĬASE WHEN cu.activebool THEN 'active' ELSE '' END AS notes, PostgreSQL CREATE VIEW exampleįor example, in our sample database, we have four tables: A query can be a simple SELECT statement or a complex SELECT statement with joins. The simplest syntax of the CREATE VIEW statement is as follows: CREATE VIEW view_name AS query Code language: SQL (Structured Query Language) ( sql )įirst, you specify the name of the view after the CREATE VIEW clause, then you put a query after the AS keyword. To create a view, we use CREATE VIEW statement.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |