logo-MindMajix
A
Aryan Sharma

Posted on 23rd July 2024|133 views

0
votes

Postgresql Create Table If Not Exists

How to create a table if that doesn't exist in PostgreSQL?

1 answers
Answers
P
veerubhotla sowmithri

Posted on 23rd July 2024| views

  • First, we use the Create Table statement to create a table in the PostgreSQL.
  • Now name the table_name.
  • Now by providing columns with column names, type of data to be stored in columns and size of the columns in parentheses(size).
  • The primary key defines a record, so it points a table or set of information.

CREATE DATABASE employee_details;

CREATE TABLE employee_data(

id INT not null,

name VARCHAR(20) unique not null,

dob DATETIME not null,

email VARCHAR(40) unique,

created_on TIMESTAMP not null,

last_login TIMESTAMP

Primary key(id)

);

 

Output:

Column_name Column_type      
Size
(KEY) id Int  Not null
name varchar 20
dob datetime Not null
email varchar 40
created_on Timestamp Not null
Last_login Timestamp Not null

 

 

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number