Skip to main content

SQL Commands - Basics

 

  • SQL stands for Structured Query Language
  • SQL lets you access and manipulate databases

 SQL database is a collection of tables that stores a specific set of structured data.

Database Management Systems (DBMS) are software systems used to store, retrieve and run queries on data. A DBMS serves as an interface between an end-user and a database, allowing users to create, read, update, and delete data in the database.

eg : MySQL, Oracle DB, etc. 

RDBMS stands for Relational Database Management System. RDBMS is a program used to maintain a relational database. RDBMS uses SQL queries to access the data in the database.

Types of Commands Available in SQL : 

  • Data Definition Language 
  • Data Manipulation Language 
  • Data Query Language 
  • Data Control Language 
  • Transactional Control Language 

 Data Definition Language : Set of commands used to create and modify the structure of database objects in a database.

  • create, alter, drop, truncate

Create :  To create a database and table. 


Alter :
To add, change, modify or drop columns in an existing table. 


 
  

 

 


 

 

 

 

 


 

 

 

 

 

Truncate: To delete the data inside a table but not the table itself (retains structure of the table)


 


 

 

Drop:  To remove/delete an entire table. 


 

 Data Manipulation Language :  A set of commands used to add (insert), delete (delete), and alter (update) data in a database. 

  • insert, update, delete

Insert: To add new records/rows in a table 

Syntax


 

 

Update:  Modifies existing records in a table based on a condition specified by where clause



 

 

Delete: Deletes existing rows in a table


 

 

Data Query Language :   Commands used to make various queries in the table

  • select
Select: To retrieve/query an SQL table

Basic Syntax

 

 

Data Control Language:  Allows to set up and control BigQuery resources using GoogleSQL query syntax.

  • grant, revoke  
Grant: To provide access or privileges on the database objects to the users. 
 

 
 
 
 
 
 
An entity contained within a database is an object, eg: tables 
 
Revoke: To revoke granted permissions/privileges 

 
 
 
 
Transactional Control Language :  Used to allow/administer changes to DML commands, in effect governing transactions. 
  • commit, rollback 
Commit : Ends the transaction to save the transaction changes to  physical data files. There is no option to undo the transaction after a commit is issued. 
                 Syntax: 
                                 
                                  ----------SQL statements------------
                                  commit; 
 
Rollback: In a realtime transaction, up until a commit is executed there is an option to rollback a transaction so that the actual data can be retained.
              Syntax: 
                             
                             ----------------SQL statements------------
                             rollback; 
 
[DCL and TCL  query languages are used in advanced/realtime applications]
 
 
 
                                                                                                                                                             
  

Popular posts from this blog

Artificial intelligence on Cloud

  Cloud computing is a technology model that enables convenient, on-demand access to a shared pool of computing resources (such as servers, storage, networking, databases, applications, and services) over the internet. Instead of owning and maintaining physical hardware and infrastructure, users can access and use computing resources on a pay-as-you-go basis, similar to a utility service.  Cloud computing also has deployment models, indicating how cloud services are hosted and made available to users: Public Cloud: Services are provided over the public internet and are available to anyone who wants to use or purchase them. Examples include AWS, Azure, and Google Cloud. Private Cloud: Cloud resources are used exclusively by a single organization. Private clouds can be hosted on-premises or by a third-party provider. Hybrid Cloud: Combines elements of both public and private clouds. It allows data and applications to be shared between them, offering greater flexibility a...

Mathematics for Artificial Intelligence : Multivariate Analysis

 A simplified guide on how to prep up on Mathematics for Artificial Intelligence, Machine Learning and Data Science: Multivariate Analysis (Important Pointers only)   Module VIII : Multivariate Analysis  Multivariate analysis is a branch of statistics that deals with the observation and analysis of more than one statistical outcome variable at a time. It is used to understand the relationships between multiple variables simultaneously and to model their interactions. I. Principal Component Analysis (PCA). Principal Component Analysis (PCA) is a statistical technique used to simplify a dataset by reducing its dimensions while retaining most of the variance in the data. Important Concepts: Dimensionality Reduction : PCA reduces the number of dimensions (features) in the dataset while preserving as much variability (information) as possible. Principal Components : These are new, uncorrelated variables formed from linear combinations of the original variables. The first prin...

Natural Language Processing - I

    Natural Language Processing is a subfield of AI that focuses on the interaction between computers and human languages. The primary goal of NLP is to enable machines to understand, interpret, and generate human language in a way that is both meaningful and valuable. NLP in AI involves the development of algorithms and models that allow computers to process and analyze natural language data. This includes tasks such as text parsing, sentiment analysis, language translation and speech recognition. NLP applications can be found in various domains, including virtual assistants, chatbots, language translation services and sentiment analysis tools.  Tasks of NLP :   Text Classification: Sentiment Analysis: Determining the sentiment expressed in a piece of text (positive, negative, neutral). Topic Classification: Categorizing a document or piece of text into predefined topics or categories. Named Entity Recognition (NER): Identifying and classifying entiti...