Q:

Write a postgre sql statement to create the structure of a table dup_countries similar to countries

0

Write a  postgre sql statement to create the structure of a table dup_countries similar to countries.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

CREATE TABLE dup_countries AS 
(SELECT * 
FROM countries)  
WITH NO DATA;

Output:

postgres=# CREATE TABLE dup_countries AS (
postgres(# SELECT *
postgres(# FROM countries)
postgres-# WITH NO DATA;
SELECT 0

Here is the command to see the structure of the created table :

postgres=# \d dup_countries
           Table "public.dup_countries"
    Column    |         Type          | Modifiers
--------------+-----------------------+-----------
 country_id   | character varying(3)  |
 country_name | character varying(45) |
 region_id    | numeric(10,0)         |

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now