Structured Query Language

Structured Query Language (SQL) is one of the languages used to view or change data in databases.[1] The statements used in this language are called SQL…

Structured Query Language

Structured Query Language (SQL) is one of the languages used to view or change data in databases.[1] The statements used in this language are called SQL queries.[2]

Basic use of SQL queries is to:

  • Get data from the database (the SELECT command)
  • Add data to the database (the INSERT command)
  • Change data in the database (the UPDATE command)
  • Remove data from the database (the DELETE command)
  • Set up the database to hold data (the CREATE and ALTER commands)

Examples

This is a simple SQL Query which is used to show all values stored in column named 'my_column' from the data table named 'my_table'.

SELECT my_column FROM my_table;

Here is an example of inserting new information into a table called 'people.' The query first specifies the table as 'people', then the columns in which data is going to be inserted into, and the data that is going into these columns. As a result, data will be added into the columns in the same order the column names are listed in the first brackets: (first_name, last_name, age, favorite_food).

INSERT INTO people (first_name, last_name, age, favorite_food) VALUES ("Bob", "Page", "42", "Hamburgers");

In the example below the columns aren't listed. This would result in an attempt to add the data into the table in the order the values are listed.

INSERT INTO people VALUES ("Bob", "Page", "42", "Hamburgers");

Doing the above (without naming the columns) might result in inputting the data in an incorrect column or the statement might not run correctly - when the value types are mismatched (for example trying to input a word into a column storing only numbers).

References

  1. ↑ "What is a Database? | Data Basecamp". 2022-02-26. Retrieved 2022-08-14.
  2. ↑ "Structured Query Language (SQL) | Data Basecamp". 2021-12-26. Retrieved 2022-07-01.



Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.