Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Empowering you to understand your world

How To Create A Table In PostgreSQL

Before you can start saving data, you will have to create a table in your PostgreSQL database. Let’s create a table and call it ‘batteries’ for now. You can create a PostgreSQL tale using the ‘CREATE TABLE‘ command. The following table has three columns: modeltype, and capacity.

CREATE TABLE batteries (

model varchar(60),
type varchar(60),
capacity int

);

Once you’ve pressed enter, PostgreSQL should have displayed ‘CREATE TABLE‘.

‘varchar(80)’ and ‘int’ are data type declarations. ‘int’ means integer, which is useful for storing numbers (not floating point numbers), and you can use the ‘numeric’ data type to store decimals. ‘varchar(60)’ means variable characters (up to 60 of them, as I defined in brackets). This is useful for fields containing a combination of numbers and letters (for example: strings) which you don’t intend to perform mathematical operations on.

Note: You don’t have to spread your statements out over multiple lines as shown above. You can also type commands on a single line as you see fit. Usually, typing on a single line is perfectly fine for brief statements.

Subscribe to our newsletter
Get notified when new content is published