In this article, the most basic statement used in SQL is being discussed.
Basic statement: select
- There are large amounts of data available everywhere.
- The data is stored in a sequential order in form of a table.
- Each table consists of a row which represents a unique record and column represents a field.
- Schemas are used to arrange the tables in a logical order.
- In order to extract particular data from the tables, queries are being used which is written in Structured Query Language(SQL).
- To query data, select statement is used.
select select_list; from schema_name.table.name;
In order to retrieve all the columns from a table, select* is being used.
Syntax - select* from table_name;
Points to remember:
- In the real time databases, select* isn’t recommended for use because it retrieves the data more than your requirements.
- It results in slow functioning of the application.
- In case, the user adds more columns to the table, the select* statement retrieves all the columns including the new ones resulting in crashing of the application.
If the user wants to retrieve the name of the student pursuing Computer Science, the query is as follows:
select name from course.student where course='cse'
Note that course is the name of the schema and student is the name of the table.
The output will be retrieved as follows:
To retrieve the query, another statement where is being used which will be discussed in further articles.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Insert Into Select statement in MS SQL Server
- SELECT INTO statement in SQL
- Delete statement in MS SQL Server
- Insert statement in MS SQL Server
- Select top in MS SQL Server
- SQL | DESCRIBE Statement
- SQL | MERGE Statement
- Join statement in JCL
- SQL | Case Statement
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- Batch statement in Cassandra
- MERGE Statement in SQL Explained
- SQL | INSERT IGNORE Statement
- MySQL | CREATE USER Statement
- SQL | SELECT Query
- SQL | SELECT TOP Clause
- PHP | MySQL Select Query
- SELECT Operation in Relational Algebra
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.