Friday, 8 February 2019
postgres tutorial 6 select into, create as
SELECT
column_list
INTO [ TEMPORARY | TEMP | UNLOGGED ] [ TABLE ] new_table_name
FROM
table_name
WHERE
condition;
creates a new table named film_r
SELECT
film_id,
title,
rental_rate
INTO TABLE film_r
FROM
film
WHERE
rating = 'R'
AND rental_duration = 5
ORDER BY
title;
SELECT
*
FROM
film_r;
creates a temporary table
SELECT
film_id,
title,
length
INTO TEMP TABLE short_film
FROM
film
WHERE
length < 60
ORDER BY
title;
------------------------
CREATE TEMP TABLE new_table_name
AS query;
CREATE TABLE IF NOT EXISTS film_rating (rating, film_count)
AS
SELECT
rating,
COUNT (film_id)
FROM
film
GROUP BY
rating;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment