How To Query Databases

Table of contents:

How To Query Databases
How To Query Databases

Video: How To Query Databases

Video: How To Query Databases
Video: Query a SQL database 2024, May
Anonim

Databases are a systematized collection of data structured along similar lines for storage and processing by a computer. This programming object allows you to work with large volumes of materials without putting a lot of effort into their use, modification and disposal. The universal language for working with databases is SQL.

How to query databases
How to query databases

Instructions

Step 1

In databases, information is contained in the form of tables, each table has its own structure and size, but they all obey the same commands for creating, selecting, modifying and deleting data. Working with databases is carried out in the universal query language SQL.

Step 2

Commands in the query language are defined using operators, which can be divided into 4 main types according to their field of application: data definition, data manipulation, data access definition, and transaction management.

Step 3

The most common group of operators is data manipulation. This type of activity is available to database users who are deprived of administrator rights, and allows them to work with the desired tables.

Step 4

SQL statements are the English name for verbs that denote the corresponding action: create - create, insert - add, update - modify, and delete - delete. They have the following structure: select,…, from; - selection from the entire table; select, …, from where = and / or =; - selection from the table according to the conditions; select * from; - selection of all data from the table.

Step 5

insert into () values (); - adding a row with specific fields to the table; insert into values (); - adding all fields to the table, by default. update set =; - changing one field in all records of the table; update set = where =; - data modification according to certain conditions.

Step 6

delete from; - deleting all records from the table; delete from where =; - removal under certain conditions.

Step 7

Any request is a transaction. In SQL, it is possible to execute a query and see its result and only then complete the action. This makes it possible to go back a step if the execution of the request for some reason led to unexpected consequences.

Step 8

The corresponding control operators are responsible for executing transactions: commit - confirmation, rollback - rollback and savepoint - splitting the transaction.

Step 9

Database administrators have access to all table data and can create tables, open / close access, etc. Their prerogative is data definition operators and data access: create table (,…,); - creating a new table.alter table [add, modify, drop] column; - changing the table (adding, modifying, deleting fields).

Step 10

drop table; - deleting a table. This operation can be performed only if the table is not linked to other tables by certain fields. If so, you must first delete these links and then try deleting again.

Step 11

Operators for determining access to data: grant - grant [access], revoke - close, deny - deny (stronger than revoke, since it denies all permissions).

Recommended: