• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
ExamTurf

Exam Turf

  • Categories
    • Exam Preparations
      • All Exams
      • Popular
        • UPSC-PSC
        • SSC Exams
        • Bank Exams
        • Railway Exams
        • Defence Exams
        • IIT JEE/Engineering
        • NEET/Medical
        • State PSC
        • NET Exams
        • GATE & ESC
        • IIT-JAM
        • NEET PG
        • TET Exams
        • CAT/MBA
        • CA & CS
        • State CET
        • CLAT and Law
        • State Exams
      • Finance Exam Prep
        • ACCA
        • CFP®
        • CMA®
        • CPA
        • CAIA®
        • CFA®
        • ChFC®
        • CGMA®
        • Financial Modeling
        • FRM®
        • CCP
        • CISA
        • CIA
      • Project Management
        • PMP
        • CAPM
        • CSM
        • CompTIA Project+
        • ACP
        • PRINCE2
        • CPD
        • Project Manager IAPM
        • PPM
        • MPM
        • APM
        • CPMP
        • CSSBB
        • CSSGB
        • PMC
        • BVOP
        • GPM-IPMA
        • PgMP
        • PMI-RMP
        • PMI-PBA
        • PMI-ACP
        • Others
      • Quality Management
        • CQI
        • CQPA
        • CQT
        • CRE
        • CSSBB
        • CSSGB
        • CSSYB
        • CSQE
        • Quality Management Exam Prep
      • IT and Software
        • AWS Exams
        • CCSP
        • CDPSE
        • CDP
        • CEH
        • CISM
        • CISSP
        • CCIE
        • CCNA
        • CCNP
        • Microsoft Azure
        • MCSA
        • CMDBA
        • Salesforce
        • CompTIA A+
        • MTA
        • PMP
        • Oracle Certification
        • GIAC
        • ITIL
        • Others
      • Data Science Exam Prep
        • CAP
        • CCA
        • CCP
        • DASCA Certifications
        • EMCDS
        • Google Certifications
        • IBM Certifications
        • Azure
        • Open CDS
        • SAS
        • Tensorflow
        • Data Science Exam Prep
      • Digital Marketing
        • Facebook
        • Google AdWords
        • Hootsuite
        • HubSpot
        • PCM Digital
        • AMA Certifications
        • Others
    • K-12
      • Class 12
      • Class 11
      • Class 10
      • Class 9
      • Class 8
      • Class 7
      • Class 6
      • Graduation
    • Data Science
      • Big Data
        • Hadoop
        • Splunk
        • Apache Pig
        • Apache Spark
        • Hive
        • Mahout
        • Apache Storm
        • Pyspark
        • Sqoop
        • Kafka
        • Others
      • Deep Learning
        • Tensorflow
        • Octave
        • OpenCV
        • NLP
        • Scikit-Learn
        • Python
      • Machine Learning
        • Tensorflow
        • Octave
        • OpenCV
        • NLP
        • Scikit-Learn
        • Python
      • Artificial Intelligence
        • Python
        • Tensorflow
        • Deeplearning
        • Pytorch
        • IoT
      • Data Analysis
        • R
        • SAS
        • Devops
        • Docker
        • Kubernetes
        • Keras
      • Neural Networks
        • Keras
        • R
        • Python
        • Pytorch
        • AI
        • BI
      • Python
        • Seaborn
        • Pandas
        • Numpy
        • Kubernetes
        • Keras
        • Pytorch
        • Pyspark
      • Business Intelligence
        • SAS
        • Power BI
        • Qliksense
      • Business Analytics
        • SEO
        • Google Analytics
        • Marketing Analytics
        • Sales Analytics
        • Fraud Analytics
        • Customer Analytics
        • Talend
      • Cloud Computing
        • AWS
        • Cloud
        • Azure
      • Data Visualization
        • SSIS
        • Qlikview
        • Matplotlib
        • Seaborn
        • Pandas
        • Numpy
        • Kibana
      • Statistics
        • Minitab
        • Tableau
        • SPSS
        • Eviews
        • Predictive Modeling
        • Time Series
        • Forecasting
      • Database
        • Informatica
        • SQL
        • CloverETL
        • CouchDB
        • Solr
        • Cassandra
    • Development
      • All Development
      • Web Development
        • All Web Development
        • JavaScript
        • React
        • CSS
        • Angular
        • PHP
        • Node.Js
        • WordPress
      • Data Science
        • All Data Science
        • Python
        • Deep Learning
        • Machine Learning
        • Data Analysis
        • Artificial Intelligence
        • R
        • Tensorflow
        • Neural Networks
      • Mobile Development
        • All Mobile Development
        • Google Flutter
        • Android Development
        • iOS Development
        • Swift
        • React Native
        • Dart Programming
        • Kotlin
        • Redux Framework
      • Programming Languages
        • All Programming
        • Python
        • Java
        • RPA Robotics
        • C++ and C#
        • React
        • JavaScript
        • C
        • Go Programming
        • Spring Framework
      • Game Development
        • All Game Development
        • 2D Game Development
        • 3D Game Development
        • Unity
        • Game Fundamentals
        • Unreal Engine
        • RPA Robotics
        • C++ and C#
        • 3D Max
        • Blender
      • Database Design
        • All Database Design
        • SQL
        • MySQL
        • Oracle SQL
        • MongoDB
        • Oracle Certification
        • SQL Server
        • Apache Kafka
        • PostgreSQL
        • Database Programming
      • Software Testing
        • All Software Testing
        • Selenium WebDriver
        • Java
        • Automation Testing
        • Selenium Testing Framework
        • API Testing
        • Cypress.io
        • REST Assured
        • Python
      • Software Engineering
        • All Software Engineering
        • Coding Interview
        • Kubernetes
        • Certified Kubernetes Application Developer
        • Data Structures
        • Software Practices
        • Microservices
        • Python
        • Spring Boot
        • Elasticsearch
      • Development Tools
        • All Development Tools
        • Docker
        • Kubernetes Python
        • Git
        • DevOps
        • Jenkins
        • JIRA
        • AWS Certified Solutions Architect - Associate
        • Continuous Integration
        • Confluence
      • No Code Development
        • All No-Code Development
        • Elementor
        • WordPress
        • Microsoft
        • Software Development
        • Web Design
        • Others
    • Business
      • All Business
      • Entrepreneurship
        • All Entrepreneurship
        • Business Plan
        • Business Fundamentals
        • Entrepreneurship Fundamentals
        • Business Strategy
        • Social Media Strategy
        • Branding Strategy
        • Startup
        • Home Business
      • Communications
        • All Communications
        • Communication Skills
        • Presentation Skills
        • Public Speaking
        • Business Writing
        • Persuasion
        • Email Etiquette
        • Business Communication
      • Sales
        • All Sales
        • Sales Skills
        • B2B Sales
        • Presentation Skills
        • Business Development
        • Lead Generation
        • Cold Email
        • Customer Service
      • Business Strategy
        • All Business Strategy
        • Digital Marketing
        • Google Ads (Adwords)
        • TOGAF 9 Foundation
        • Strategic Planning
        • Management Consulting
        • Agile
      • Operations
        • All Operations
        • Six Sigma
        • Six Sigma Green Belt
        • Supply Chain
        • Quality Management
        • Process and Automation
        • Six Sigma Black Belt
        • Lean
        • Six Sigma Yellow Belt
      • Project Management
        • All Project Management
        • PMP
        • PMBOK
        • Agile
        • Scrum
        • PMI-ACP
        • CAPM
        • Risk Management
        • Professional Scrum Master
      • Business Law
        • All Business Law
        • Product Management
        • Leadership
        • Management Skills
        • Business Process Management
        • Business Strategy
        • ISO 9001
        • Risk Management
        • Agile
        • Quality Management
      • Business Analytics and Intelligence
        • All BA and BI
        • Microsoft Power BI
        • SQL
        • Tableau
        • Business Analysis
        • Business Intelligence
        • Data Analysis
        • MySQL
        • Data Modeling
        • Big Data
      • Human Resources
        • All Human Resources
        • Recruiting
        • Instructional Design
        • Communication
        • Hiring
        • Leaderships Management
        • Conflict Management
        • HR Analytics
        • Talent Management
      • Industry
        • All Industry
        • Communication Skills
        • Presentation Skills
        • Public Speaking
        • Business Writing
        • Persuasion
        • Email Etiquette
        • Managing Leadership
      • E Commerce
        • All E-Commerce
        • Dropshipping
        • Search Engine
        • WordPress for Ecommerce
      • Media
        • All Media
        • Communication Skills
        • Presentation Skills
        • Public Speaking
        • Business Writing
        • Persuasion
        • Email Etiquette
        • Managing Leadership
      • Real Estate
        • All Real Estate
        • Investing
        • Risk Profiling
        • Construction
        • Financial Modeling
        • Management
        • Real Estate Finance
        • Marketing
      • Other Business
        • Product Management
        • Leadership
        • Management Skills
        • Business Process Management
        • Business Strategy
        • ISO 9001
        • Risk Management
        • Agile
        • Quality Management
    • Finance & Accounting
      • All Fin and Accounting
      • Taxes
        • All Taxes
        • Tax Preparation
        • Goods and Services Tax
        • History
        • Home Business
        • Value Added Tax (VAT)
        • QuickBooks Online
        • Financial Accounting
        • Entrepreneurship Fundamentals
        • Personal Finance
      • Money Management Tools
        • All Money Management Tools
        • QuickBooks Online
        • QuickBooks
        • Excel
        • SAP FICO
        • Xero
        • Financial Modeling
        • Excel Analytics
        • Financial Analysis
      • Investing and Trading
        • All Investing & Trading
        • Stock Trading
        • Technical Analysis
        • Forex
        • Investing
        • Options Trading
        • Day Trading
        • Algorithmic Trading
        • Financial Analysis
        • Financial Trading
      • Financial Modelings
        • All Financial Modeling & Analysis
        • Financial Analysis
        • Financial Modeling
        • Finance Fundamentals
        • Excel
        • History
        • Investing
        • Python
        • Investment Banking
        • Financial Management
      • Finance Exam Prep
        • All Finance Cert & Exam Prep
        • CFA
        • Certified Management Accountant (CMA)
        • Financial Markets
        • Quantitative Finance
        • ACCA
        • Financial Management
        • ANBIMA Certification
        • Corporate Finance
        • Fixed Income Securities
      • Finance
        • All Finance
        • Personal Finance
        • Investment Banking
        • CFA
        • Finance Fundamentals
        • Financial Management
        • Financial Analysis
        • Corporate Finance
        • Company Valuation
        • Excel
      • Economics
        • All Economics
        • Microeconomics
        • Macroeconomics
        • Stata
        • Entrepreneurship Fundamentals
        • Econometrics
        • Finance Fundamentals
        • Political Science
        • Regression Analysis
      • Crypto and Blockchain
        • All Cryptocurrency & Blockchain
        • Cryptocurrency
        • Bitcoin
        • Blockchain
        • Personal Finance
        • Day Trading
        • Bitcoin Trading
        • Algorithmic Trading
        • Ethereum
        • Technical Analysis
      • Compliance
        • All Compliance
        • Anti-Money Laundering
        • Risk Management
        • Sarbanes-Oxley (SOX)
        • Internal Auditing
        • CAMS Certification
        • CIA
        • IFRS
        • Financial Risk Manager (FRM)
        • Certified Fraud Examiner (CFE)
      • Acc and Bookkeeping
        • All Accounting & Bookkeeping
        • History
        • Finance Fundamentals
        • Financial Accounting
        • Bookkeeping
        • Financial Statement
        • Xero
        • Cost Accounting
        • Tally.ERP
        • IFRS
    • IT & Software
      • Robotics RPA
      • IT Certification
        • All IT Certification
        • AWS Certification
        • Microsoft Certification
        • AWS Certified Solutions Architect - Associate
        • AWS Certified Cloud Practitioner
        • CompTIA - A
        • Cisco CCNA
        • AWS Certified Developer - Associate
        • CompTIA Security+
        • Amazon AWS
      • Network and Security
        • All Network & Security
        • Ethical Hacking
        • Cyber Security
        • Network Security
        • CompTIA Security+
        • Penetration Testing
        • IT Networking Fundamentals
        • CompTIA Network+
        • Cisco CCNA
        • Terraform
      • Hardware
        • All Hardware
        • Arduino
        • PLC
        • Electronics
        • Microcontroller
        • Raspberry Pi
        • Embedded Systems
        • FPGA
        • HMI
        • RTOS
      • Operating Systems
        • All Operating Systems
        • Linux
        • Linux Administration
        • Windows Server
        • Shell Scripting
        • Active Directory
        • LPIC-1: Linux Administrator
        • PowerShell
        • VMware Vsphere
        • Operating System Creation
      • All IT and Software
        • All Other IT & Software
        • Docker
        • Python
        • Kubernetes
        • Devops
        • Algorithms
        • Ansible
        • AWS Certified Solutions Architect - Professional
        • Java
        • AWS Certification
    • Office Productivity
      • All Office Productivity
      • Microsoft
        • All Microsoft
        • Words
        • PowerPoint
        • SQL
        • SharePoint
        • Excel
        • OutLook
        • OneDrive
        • MS Project
        • Azure
      • Apple
        • All Apple
        • iOS
        • Mac Basics
        • macOS
        • excel
        • MS Project
        • Mac Pages
        • Office Productivity
        • Video Editing
        • Microsoft Word
      • Google
        • All Google
        • Google Analytics
        • Google Tag
        • Google Drive
        • Google Apps
        • Excel
        • Gmail Productivity
        • Google Data Studio
        • Google Docs
        • Google Office
      • SAP
        • All SAP
        • SAP ABAP
        • SAP FICO
        • SAP FICO
        • SAP Financial Accounting
        • SAP HCM
        • Supply Chain
        • SAP MM
        • SAP S/4HANA
        • SAP SD
      • Oracle
        • All Oracle
        • Primavera
        • SQL
        • Business Intelligence
        • Database
        • PLSQL
        • Data Integrator
        • Exam Prep
      • Other Office Productivity
        • All Others
        • ServiceNow
        • Time Management
        • Personal Productivity
        • Salesforce
        • QuickBooks
    • Personal Development
      • All Personal Development
      • Personal Transformation
        • All Personal Transformation
        • Life Coach Training
        • Neuro-Linguistic Programming
        • Mindfulness
        • Personal Development
        • Life Purpose
        • Meditation
        • CBT
        • Neuroscience
      • Personal Productivity
        • All Personal Productivity
        • Time Management
        • Focus Mastery
        • Speed Reading
        • Goal Setting
        • Organization
        • PowerShell
        • Procrastination
        • Habits
      • Leadership
        • All Leadership
        • Management Skills
        • Manager Training
        • Communication Skills
        • Public Speaking
        • Conflict Management
        • Listening Skills
        • Relationship Building
        • Spirituality
      • Career Development
        • All Career Development
        • Resume and CV Writing
        • Interviewing Skills
        • Job Search
        • Personal Networking
        • Life Coach Training
        • Soft Skills
        • Business Communication
      • Personal Brand Building
      • Time Management
      • Communication
    • Design
      • All Design
      • Web Design
        • All Web Design
        • Photoshop
        • After Effects
        • HTML CSS Web
        • Adobe Premiere
        • Video Editing
        • Digital Art
        • AutoCAD
        • Graphic Design
      • Graphic Design Illustration
        • All Graphic Illustration
        • Graphic Design
        • Photoshop
        • HTML CSS Web
        • Drawing
        • Digital Painting
        • InDesign
        • Figure Drawing
      • Design Tools
        • All Design Tools
        • Photoshop
        • After Effects
        • HTML CSS Web
        • Adobe Premiere
        • Video Editing
        • Digital Art
        • AutoCAD
        • Graphic Design
      • Game Design
      • User Experience Design
        • All User Experience
        • User Interface
        • Adobe XD
        • Figma
        • Web Design
        • Product Design
        • Sketch
        • Axure
        • InVision Studio
      • Design Thinking
        • All Design Thinking
        • WordPress
        • CSS
        • Sketch
        • HTML
        • Photoshop
        • User Interface
        • HTML5
        • Adobe XD
      • 3D and Animation
        • All 3D & Animation
        • Blender
        • 3D Modeling
        • After Effects
        • Motion Graphics
        • 3D Animation
        • 3D Texturing
        • zBrush
        • 3ds Max
        • Fusion 360
      • Fashion Design
        • All Fashion Design
        • Fashion
        • HTML CSS Web
        • Sewing
        • Jewelry Design
        • Photoshop
        • T-Shirt Design
        • Anime
        • Marvelous Designer
      • Architectural Design
      • Interior Design
      • Other Design
    • Marketing
      • All Marketing
      • Digital Marketing
        • All Digital Marketing
        • Google Ads (Adwords)
        • Social Media
        • Internet Marketing
        • Email Marketing
        • Google Analytics
      • SEO Optimization
        • All SEO Optimization
        • SEO
        • WordPress
        • Keyword Research
        • Local SEO
        • Link Building
        • Google my Business
        • SEO Audit
        • Google Ads (Adwords)
      • Social Media
        • All Social Media
        • Instagram Marketing
        • Facebook Ads
        • Facebook Marketing
        • PPC Advertising
        • Social Media Management
        • Instagram Photography
        • TikTok Marketing
      • Branding and Strategy
        • All Branding
        • Business Branding
        • Personal Branding
        • Brand Management
        • Graphic Design
        • Social Media
      • Marketing Fundamentals
        • All Fundamentals
        • Google Ads (Adwords)
        • SMM
        • Marketing Strategy
        • Internet Marketing
        • Sales Marketing
        • Email Marketing
        • Google Analytics
      • Analytics and Automation
        • All Marketing Analytics
        • Google Analytics
        • Google Analytics IQ
        • Data Analysis
        • Marketing Analytics
        • SQL
        • Google Tag Manager
        • Marketing Automation
      • Public Relations
        • All Public Relations
        • Leadership
        • Business Communication
        • Public Speaking
        • Brand Building
        • Startup
        • Planning
        • Time Management
      • Advertising
        • All Advertising
        • Instagram Marketing
        • Facebook Ads
        • Facebook Marketing
        • PPC Advertising
        • Social Media Management
        • Instagram Photography
        • TikTok Marketing
      • Sales Management
      • Content Marketing
        • All Content Marketing
        • Time Management
        • Branding Strategy
        • Content Writing
        • Content Creation
        • WordPress
      • Growth Hacking
        • All Growth Hacking
        • Digital Marketing
        • App Marketing
        • Lead Generation
        • SEO
        • Instagram Marketing
        • Excel
        • B2B Sales
      • Affiliate Marketing
        • All Affiliate Marketing
        • ClickBank
        • SEO
        • CPA Marketing
        • Teespring
        • Internet Marketing
        • Home Business
      • Product Marketing
        • All Product Marketing
        • Marketing Plan
        • Self-Publishing
        • Product Management
        • Voice-Over
        • Marketing Management
        • Amazon PPC Advertising
        • Facebook Marketing
    • Teaching and Academics
      • Medical
      • Law
      • Humanities
      • Math
        • All Math
        • Calculus
        • Statistics
        • Linear Algebra
        • Probability
        • Algebra
        • Trigonometry
        • Discrete Math
        • Geometry
      • Science
        • All Science
        • Physics
        • Solar Energy
        • Anatomy
        • Chemistry
        • Biology
        • Neuroscience
        • Physiology
        • Research Paper Writing
        • AP Physics
      • Online Education
      • Social Science
        • All Social Science
        • Counseling
        • History
        • Economics
        • Geography
        • Social Psychology
        • Others SS
      • Teacher Training
      • Test Prep
        • All Test Prep
        • CFA
        • PMP
        • Devops Test Prep
        • FRM
        • CEH Ethical Hacker
        • GMAT
        • Azure
        • AWS
        • Others
      • Other Teaching & Academics
  • Teach at EXAMTURF
  • Login
  • Sign Up

PostgreSQL Variables

Home » Data Science » PostgreSQL » PostgreSQL Variables

March 18, 2021 by Ginius Academy For UPSC CAT

TwitterLinkedInFacebookWhatsApp

PostgreSQL Variables

Introduction To PostgreSQL Variables

The PostgreSQL variable is a name of a memory location that is used to store the data temporarily at the time of function execution. They have a particular data type give to the following such as text, char, date, time, Boolean, etc. The PostgreSQL variables are not defined with the default value, it can be initialized to the NULL value. By using a function or code block, we can alter the value stored in the PostgreSQL variable.

Uses Of Variables

The uses of variables in PostgreSQL are listed as follows:

  • They are used to implement the particular function it can be defined within the function under the DECLARE keyword.
  • When the time of function execution, we can store the data temporarily in the PostgreSQL variable.
  • It allows that to modify the data that can be stored within the variable.
  • It does not allow that to change the value of data when it is defined as CONSTANT.
  • PostgreSQL is not defined as the CONSTANT, then we can declare with a default value and we can modify it later.

How To Initialize The Variables?

We can initialize a variable by giving an initial value while creating the variable.

Example:

Code:

DECLARE num_of_students integer := 200;

  • The above example is used to declare the PostgreSQL variable. The initial value of the variable is 200. The name of the variable is the number of students and the datatype is an integer.
  • We can initialize the variable only after the declaration of the variable.

Code:

DECLARE num_of_students integer;

The statement is used to declare the PostgreSQL variable only.

From the above example:

Code:

num_of_students:=200

The statement is used to initialize a PostgreSQL variable of the name.

How To Declare Variables?

Declaration of Variable is can be understood by the following statement.

Code:

variable_name data_type [:= expression];

  • The first step is to give the specific name to a variable like an index or counter.
  • The second step is to define the data type of variables like INTEGER, NUMERIC, VARCHAR, and CHAR.
  • The third step is giving the default value to the variable. If you don’t know the value then the value is initialized in NULL.

Examples of PostgreSQL Variables

Given below are the examples mentioned:

Example #1

Code for without DEFAULT Keyword.

Code:

/*"Initial_val_without_default_keyword"()*/
-- FUNCTION: public."Initial_val_without_default_keyword"()
-- DROP FUNCTION public."Initial_val_without_default_keyword"();
CREATE OR REPLACE FUNCTION public."Initial_val_without_default_keyword"()
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$DECLARE
def_var integer := 100;
BEGIN
RETURN def_var;
END;
$BODY$;

SQL Statement:

Code:

SELECT public."Initial_val_without_default_keyword"()

Output:

PostgreSQL Variables Example 1.png

Example #2

Codes for with default keyword.

Code:

"Initial_val_with_default_keyword"()
-- FUNCTION: public."Initial_val_with_default_keyword"()
-- DROP FUNCTION public."Initial_val_with_default_keyword"();
CREATE OR REPLACE FUNCTION public."Initial_val_with_default_keyword"()
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$DECLARE
def_var integer default 200;
BEGIN
RETURN def_var;
END;
$BODY$;

SQL Statement:

Code:

SELECT public."Initial_val_with_default_keyword"()

Output:

Default keyword Example 2.png

Example #3

Code for constant variable without DEFAULT Keyword.

Code:

-- FUNCTION: public."Initial_val_constant_without_default_keyword"()
-- DROP FUNCTION public."Initial_val_constant_without_default_keyword"();
CREATE OR REPLACE FUNCTION
public."Initial_val_constant_without_default_keyword"(
)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$ DECLARE
def_var CONSTANT integer := 200;
BEGIN
RETURN def_var;
END;
$BODY$;

SQL Statement:

Code:

SELECT public."Initial_val_constant_without_default_keyword"()

Output:

DEFAULT Keyword Example 3.png

Example #4

Code for constant variable with the default keyword.

Code:

-- FUNCTION: public."Initial_val_constant_with_default_keyword"()
-- DROP FUNCTION public."Initial_val_constant_with_default_keyword"();
CREATE OR REPLACE FUNCTION
public."Initial_val_constant_with_default_keyword"()
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$DECLARE
def_var CONSTANT integer default 300;
BEGIN
RETURN def_var;
END;
$BODY$;

SQL Statement:

Code:

SELECT public."Initial_val_constant_with_default_keyword"()

Output:

Constant Variable Example 4.png

Example #5

Code which is gives the value to a variable after the declaration.

Code:

-- FUNCTION: public."Initial_val_later"()
-- DROP FUNCTION public."Initial_val_later"();
CREATE OR REPLACE FUNCTION public."Initial_val_later"(
)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$Declare
def_var integer ;
BEGIN
def_var:=500;
RETURN def_var;
END;
$BODY$;

SQL Statement:

Code:

SELECT public."Initial_val_later"()

Output:

Variable after the Declaration Example 5.png

Conclusion

This article explains the PostgreSQL variables, initialize and declaration of variables and its uses.

Recommended Articles

This is a guide to PostgreSQL Variables. Here we discuss the introduction, how to declare and initialize variables along with its example with code implementation. You can also go through our other suggested articles to learn more –

  1. What is PostgreSQL?
  2. How to Install PostgreSQL?
  3. PostgreSQL Versions
  4. PostgreSQL Features

Are you preparing for the entrance exam ?

Join our Data Science test series to get more practice in your preparation

View More
TwitterLinkedInFacebookWhatsApp

Data Science,  PostgreSQL

Primary Sidebar

Recent Posts

  • Voice Over Internet Protocol (VoIP)
  • Data Modeling Interview Questions
  • Resorts in Indore
  • Big Data and Artificial Intelligence
  • Shore Temple

Categories

  • Artificial Intelligence
  • Bank Exams
  • Best Resorts
  • C# Tutorial
  • CAT Exam
  • Celebrity
  • Cloud Computing
  • Data Analysis
  • Data Science
  • Database
  • Defence Exams
  • Exam Preparations
  • Finance & Accounting
  • Finance Cert and Exam Prep
  • Full Form
  • IIT JEE Preparation
  • Interview Questions
  • Interview Questions
  • IT & Software
  • Java Tutorial
  • K-12
  • Machine Learning
  • Management & Foreign Studies
  • Miscellaneous
  • Mobile Development
  • NEET Preparation
  • Operating Systems
  • Others
  • PostgreSQL
  • Programming Languages
  • Python
  • Railway Exams
  • Software Development
  • SSC Exams
  • State PSC
  • Temple
  • Top Difference Between
  • Tourist Places
  • Uncategorized
  • UPSC
  • Web Development
  • World Best Hotels
Footer

Company

  • About Us
  • Contact Us
  • Terms
  • Privacy Policy & Cookie Policy
  • Cancellation/Refund Policy

Teachers

  • Teach on Examturf
  • Instructor FAQs
  • Instructor Revenue Share
  • Marketing Tips for Instructor
  • Instructor Success Stories

Learners

  • Learners FAQs

Affiliate

  • Become an Affiliate
  • Affiliate Success Stories

Resources

  • Blog
  • Exam Preparation
  • UPSC Exams
  • SSC Exams
  • IIT JEE
  • NEET Preparations
  • Data Science
  • Development

Featured Tests

  • All Featured Tests
  • Mini Quizzes
  • Comprehensive Series
  • Regular Tests
  • Exam Preparations
  • Data Science
  • Development
  • Business
  • Finance & Accounting
  • IT & Software
  • Office Productivity
  • Personal Development
  • Design
  • Marketing
  • Teaching & Academics

Copyright © 2025

Special Offer: 2000+ Selected Test Series, Mini Quizzes and Mock Tests are FREE. Offer valid for :

x