Updating joined tables

By specifying NULL as the value for a column, you can set the column to NULL despite any default value.You want to copy rows from one table to another by using a query.You do not want to copy the rows, only the column structure of the table.

Many would expect the column to taken on the null value, but, alas, a default value was specified at table creation time, so the result of the preceding INSERT is that ID takes on the value 0 (the default).But you can also update whole sets of records at once, and in very powerful ways. For example, you can delete rows in one table depending on whether or not they exist in another table.SQL even has a way, a relatively new addition to the standard, by which you can insert, update, and delete all at once. For example, you want to insert a new record into the DEPT table.That may not sound like too useful a thing now, but the MERGE statement represents a very powerful way to bring a database table into sync with an external source of data (such as a flat file feed from a remote system). The value for DEPTNO should be 50, DNAME should be “PROGRAMMING”, and LOC should be “BALTIMORE”.The INSERT statement allows you to create new rows in database tables.

Leave a Reply