How does SQL differ from Programming Languages?

SQL is Structured Query Language.
It is a set of commands used in the creation (and modification and deletion) of database structures and in the management of the data stored in it.

Different DBMS companies have adapted SQL to give it their own customization and signature, and today we have Microsoft SQL, Oracle SQL, MySQL, SQLite etc.

It differs from programming languages (Basic, Fortran, C, C++, etc) in the following ways-

  • Function
    The primary function of other programming languages is to perform actions. Eg. A program like calculator.exe performs mathematical calculations.
    The primary function of the SQL is to deal with data – the storing of it, and the handling of that which is stored.
    Eg. If you look at a database like a Venn-diagram, SQL allows you to create the diagram, put in values, and to view it.

    But to actually perform actions using that data, you will need to work with APIs (Application Programming Interfaces) of the other programming languages.

  • Structure
    Other programming languages are procedure-based. They have methods, functions, and blocks of code which perform specific tasks, and can “call” other blocks of code, and create a flow of execution. These procedures can be reused.
    SQL is non-procedural, and more a “declarative” language. It is a set of commands which run independently and stand-alone. No “calls” can be made and no set of statements can be “reused”. It is essentially a set of one-time operations on a database.
  • Loops and Recursions
    Looping and recursion are common programming logic building practices in other programming languages.
    SQL does not support this. It may be possible through modern implementations of SQL to loop – but this is making the language to tediously do something it was NOT designed to.
  • Control over the operating system
    Other programming languages offer a degree of control over their execution in the operating system environment by providing options in memory management and process and thread management.
    SQL does not provide for this.