DEV Community

vishwa v
vishwa v

Posted on

postgresql-2

Creating Table in SQL

CREATE TABLE cars (
  brand VARCHAR(255),
  model VARCHAR(255),
  year INT
);
Enter fullscreen mode Exit fullscreen mode

When creating fields in a table we have to specify the data type of each field.

For brand and model we are expecting string values, and string values are specified with the VARCHAR keyword.

We also have to specify the number of characters allowed in a string field, and since we do not know exactly, we just set it to 255.

For year we are expecting integer values (numbers without decimals), and integer values are specified with the INT keyword.

Insert data in a specific table

INSERT INTO cars (brand, model, year)
VALUES ('Ford', 'Mustang', 1964);
Enter fullscreen mode Exit fullscreen mode

For display:

SELECT * FROM cars;
Enter fullscreen mode Exit fullscreen mode

output:

 brand |  model  | year
-------+---------+------
 Ford  | Mustang | 1964
Enter fullscreen mode Exit fullscreen mode

how to check the Structure of a table in postgres.

\d your_table_name;
Enter fullscreen mode Exit fullscreen mode

*How to get unique content *

SELECT DISTINCT model
FROM cars;

Enter fullscreen mode Exit fullscreen mode

What is ERP? ERP Organizations in India

ERP (Enterprise Resource Planning) is a software system that integrates core business functions—finance, HR, inventory, sales, procurement, and manufacturing—into one unified platform. In India, ERP adoption is strong among SMEs and large enterprises, with popular providers including SAP, Oracle, Tally, Zoho, and ERPNext.

What is CRM? CRM Organizations in India

CRM (Customer Relationship Management) is software and a business strategy that helps organizations manage customer interactions, sales pipelines, and support processes. In India, leading CRM providers include Zoho, Salesforce, Freshworks, HubSpot, and TCS, serving both SMEs and large enterprises.

Top comments (0)