2

Recently I have read (in a PDF document - SQL for dummies) that SQL is actually a data sublanguage and not a programming language like C++ or Java or C# and right now I am a bit confused, because since you can develop things through SQL, I thought it is similar to other programming languages.

Could anyone explain to me what is the difference? Thanks

Ry-
  • 218,210
  • 55
  • 464
  • 476
cdrrr
  • 1,138
  • 4
  • 13
  • 44
  • 2
    Before anyone "dislike" my question, please be adivsed that I'm a novice and this is the purpose of this website anyway. – cdrrr Feb 28 '17 at 20:50
  • This site is mainly for code-specific questions. general software development questions can be asked at http://softwareengineering.stackexchange.com/. – Mark Cidade Feb 28 '17 at 20:52
  • related: [Is SQL or even TSQL Turing Complete? - stackoverflow](http://stackoverflow.com/questions/900055/is-sql-or-even-tsql-turing-complete) – SqlZim Feb 28 '17 at 20:55

4 Answers4

3

Try to write a simple but non-trivial application using nothing but standard SQL that asks the user to input their name, and outputs "Hello, ."

Maybe you could do it with some vendor-specific extensions, but then it wouldn't be standard SQL.

SQL is designed to be a domain-specific language for database queries. It's meant to be used in combination with a more fully-featured language. The SQL standard defines ways that you can write lines of SQL within the code file of C, C++ or other languages. There's no standard way to write a full standalone app using just SQL.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
2

Read the standard. The SQL/PSM part defines a full-blown programming language with loops and IF-THEN-ELSE and what have you. SQL/PSM was initially amended to the existing standard in 1996 and formally included in SQL:1999.

As Bill Karwin hinted at, SQL does not have features for UI interaction, but then the very same thing is true about the java language (no, the swing package is not part of the language), and the COBOL language, and the ALGOL language, and many many others.

SQL began life as a data sublanguage. That history is >20yrs behind us. (The "data sublanguage" portion is still the most-used and most-useful part, but that does not change the fact that technically speaking, SQL-the-language has everything it takes to be regarded as a full-blown programming language.)

Erwin Smout
  • 18,113
  • 4
  • 33
  • 52
1

According to wikipedia a sublanguage

the term "sublanguage", first used for this purpose by E. F. Codd in 1970, refers to a computer language used to define or manipulate the structure and contents of a relational database management system (RDBMS). Typical sublanguages associated with modern RDBMS's are QBE (Query by Example) and SQL (Structured Query Language).

that means that sublanguages cannot be used to develop a standalone applications but they could be incorporated with other computer programming languages to manage the application-database interaction.

radtelbi
  • 635
  • 1
  • 6
  • 18
-2

Standard SQL can only be used for defining database schemas and for querying and updating data. Database vendors have extensions to SQL (like Microsoft's T-SQL) that are full-blown programming languages.

Mark Cidade
  • 98,437
  • 31
  • 224
  • 236