[Esercizio libro Bit by Bit] Pag 161 n.17 - SQL (inglese)

bit by bit







Svolgimento dell'esercizio n. 17 a pag. 161 sul libro Bit by Bit.

Risposte
1) Control
2) Info
3) Modify tables
4) Add
5) Add
6) Remove objects 
7) Rename
8) Grant
9) Revoke
10) Select
11) Delete
12) Select
13) Delete
14) Modify 


Traccia audio scritta
Today we'll discuss different types of SQL. 
Language will also look at the main statements with some practical examples. 
Let's start with the first distinction. 
SQL can be divided into three broad categories. Data definition language, ddl data, control language, DCL and SQL, queries. Let's analyze data definition language. 
The first example of command is create which is used to create objects. 
For example, if we want to create a database with information on our students, we can write create database, all in capital letters and then the name of the database. 
In this case it is students underscore info. 
If we want to create a table, will have to write in So, let us create table and then the name of the table, which in this case is students underscore info. 
Now we have our database and our table. 
If we want to modify the table will use the commands altar. 
In this case, the statement is Alter table in capital letters and then students underscore info. 
The new statement is with ads, which is used to add a new attribute to the table. 
For example, if you want to add an ID identification code or number will write add student underscore ID. Another one is drop if we want to remove objects from the database. 
The last segment of this series is renamed which is used to rename an object. 
And now to the second category data control language, there are two statements Grant is used to give users access to privileges. 
While a revoke, is used to withdraw the Privileges given with the grant command. The Privileges that can be granted or revoked include connect inserts, select update, delete and execute. 
The last category is about the queries. 
Insert is used to add records to an existing table. 
For example, we can decide to add some fields to the table of our class such as first name, last name and ID code. 
In this case, we have to write insert into followed by the name of the table and the list of values that we want to insert, the result is insert into students underscore info values. 
First one, the school name. 
Last underscore name. Students underscore ID. Select allows the user to retrieve specific information. Imagine we want to order the info according to the students last name. 
In this case, select last underscore name from students underscore info. 
Remember that we have to use from before the name of the table? Delete is used to delete a record from a table. 
We have to specify the name of the table and the primary key which identifies, four records. 
For example, delete from students on score info where students underscore ID. 
RTS DSL, o1 s to v l to 190. We have chosen the fiscal code as the primary key because it is unique for each individual. 
If we want to modify information from a table, we have to use updates. 
Let's go back to our students database. 
And imagine we want to modify the date of birth of a student. 
In this case, update students underscore info set date of birth, then add the date. 
Imagine the date is the 25th of October 2001 And, Early specify the records by using the primary key. 
So we're students underscore ID RTS DSL, o1 s to v l to 190. 
That's all for today. 
Any questions? Remember that you will have to design your own database?

Commenti