Skip to main content

SQL Commands - Basics

 

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

 A 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

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...

Mathematics for Artificial Intelligence : Numerical Methods

 A simplified guide on how to prep up on Mathematics for Artificial Intelligence, Machine Learning and Data Science: Numerical Methods (Important Pointers only) Module VII : Numerical Methods  I. Bisection Method. A numerical technique for solving equations of the form f ( x ) = 0 . It is a type of root-finding method that repeatedly narrows down an interval where a root of the function exists. Steps: Choose the initial interval [ a , b ] [a, b] : Select two points a a and b b such that f ( a ) f(a) and f ( b ) f(b) have opposite signs. This indicates that there is at least one root in the interval [ a , b ] [a, b] . Compute the midpoint c c : Calculate the midpoint of the interval: c = a + b 2 c = \frac{a + b}{2} ​ Evaluate the function at the midpoint : Compute f ( c ) f(c) . Determine the subinterval : If f ( a ) ⋅ f ( c ) < 0 , the root lies in the interval [ a , c ] [a, c] . Set b = c . If f ( b ) ⋅ f ( c ) < 0 f(b) \cdot f(c) < 0 , the root lies in the in...

Mathematics for Artificial Intelligence: Boolean Algebra

 A simplified guide on how to prep up on Mathematics for Artificial Intelligence, Machine Learning and Data Science: Boolean Algebra (Important Pointers only)   Module VI : Boolean Algebra  I. Information Theory. Information theory, a mathematical framework developed by Claude Shannon in the mid-20th century, quantifies information and provides tools for analyzing communication systems and processes. It is at the intersection of electronic engineering, mathematics, statistics, computer science, neurobiology, physics, and electrical engineering.  Information : Information measures the reduction of uncertainty. When an event is uncertain, the receipt of a message about the event reduces this uncertainty. Information is quantified in terms of bits (binary digits). Abstractly, information can be thought of as the resolution of uncertainty. Shannon's main result, the noisy-channel coding theorem, showed that, in the limit of many channel uses, the rate of informatio...