Here's a continuation of my review of Getting Started with SQL, an O'Reilly guide by Thomas Nield, last blogged about on January 26, 2017 .
Chapter 10 is entitled Managing Data.
In this chapter we see how to insert data directly into a table. So a command like this one:
INSERT INTO ATTENDEE (FIRST_NAME, LAST_NAME) VALUES ('Stefani','Germanotta')
Specifies a table, fields in that table, and then on the next line the values to be added.
Not that in this example the VIP field for which the command did not specify a value, has a zero because that is the default value of the field specified when the table was created.
We can also use a command in the following format to insert data from one table into another, but keep in mind the data must be transferred between fields of the same type, and any fields in the receiving table that are designated 'NOT NULL' must be accounted for.
INSERT INTO ATTENDEE (FIRST_NAME, LAST_NAME, PHONE, EMAIL) SELECT FIRST_NAME, LAST_NAME, PHONE, EMAIL FROM SOME_OTHER_TABLE
If you want to delete data from a table along specified parameters, you can use this command:
DELETE FROM STATION_DATA WHERE YEAR IS 2002 AND MONTH IS 12
The SQL command to change the case of a field is as follows:
UPDATE ATTENDEE SET LAST_NAME = UPPER(LAST_NAME)
To remove a table from a database simply use the DROP command this format:
DROP TABLE ROOM