![]() |
![]() |
||||
An English-like programming language, which is used for communicating with relational database management systems (RDBMS).
SQL is used in most common databases, including:
Example SQL query - get the ID, name and price, of all products under $50:
select product_id, product_name, product_price from products where product_price < 50
Example SQL query results:
product_id product_name product_price --------------------------------------------------- 7 small widget 84.95 12 large widget 112.95 19 ultra-compact widget 899.95
The most basic SQL commands are:
There are also commands for creating and manipulating database tables. While there are standards for the SQL language, each database has it's own specific extensions or dialect for performing more complicated tasks.
Almost all current programming languages can communicate with databases using SQL, as long as a driver or connector is available, to bridge the gap between the language and the physical database.
In Java, the JDBC technology is used to execute SQL statements. The query results are returned in objects which can be iterated through to process or display the data.