ORACLE - SQL types (DELETE, INSERT, UPDATE)
Action SQL types (DELETE, INSERT, UPDATE):
The SQL are those that do not return any records are those responsible for actions such as add and delete and modify records.
Creates a DELETE SQL to remove the records from one or more of the tables listed in the FROM clause that meets the WHERE clause. This SQL deletes entire records, not to delete the contents of a particular field.
Its syntax is: DELETE FROM
WHERE TableName "test data selection" DELETE
is especially useful when you want to delete several records. In a multiple-table DELETE statement must include the table name (Tabla. *). If you specify more than one table from which to delete records, all tables must be many to one. If you want to delete all records from a table, delete the table itself is more efficient to run a delete query.
DELETE can be used to delete records from a single table or from multiple sides of a one to many. The cascade delete operations in a query only removed from several sides of a relationship.
For example, in the relationship between tables Customers and Orders, the Orders table is the part of so many cascading operations affect only the Orders table. A delete query deletes entire records, not only the data in specific fields. If you want to delete values \u200b\u200bin a specified field, create an update query to change the values \u200b\u200bto Null.
Once you have deleted records using a delete query can not be undone. If you want to know which records were deleted, first examine the results of a select query using the same criteria and then run the delete query. Keep backups of their data at all times. If you delete the wrong records may recover them from backups.
DELETE FROM Supplier WHERE City = 'Cordoba';
INSERT INTO
Adds a record in a table. It is known as a data query added. This query can be of two types: Insert a single record in a table or insert the records in another table.
To insert a single record:
In this case the syntax is: INSERT INTO TableName
(Nombrecampo1, Nombrecampo2, Nombrecampo3, .., Campon)
VALUES (value1, value2, value3 ,..., valueN)
This query recorded in the field1 value1, value2 into field2 and so on. Pay special attention to limit single quotes (') literal values \u200b\u200b(strings) and the dates in format mm-dd-yy and between characters pound (#).
To insert records from another table:
In this case the syntax is: INSERT INTO Table
[IN base_externa] (field1, field2, ..., Campon) SELECT
TablaOrigen.campo1, TablaOrigen.campo2 .... ., TablaOrigen. FROM Campon TablaOrigen
In this case, select the fields 1.2, ..., n in the source table and movie 1.2 fields, .., n of the table. SELECT status may include the WHERE clause to filter the records to be copied. If TablaOrigen table and have the same structure can simplify the syntax: INSERT INTO
TablaOrigen SELECT Table .* FROM TablaOrigen
This TablaOrigen fields are recorded in Table, to perform this operation is necessary for all fields TablaOrigen same name are contained in Table. In other words Table holds all fields TablaOrigen (same name and same type).
In this type of consultation should take special care with AutoNumber fields as accountants or to insert a value a field of this type is written the value field containing its counterpart in the source table, not increasing as it should.
can use the INSERT INTO statement to add a single record to a table using the query syntax for adding single record as shown above. In this case, your code specifies the name and value of each field in the record. You must specify each of the fields in the record that will be assigned a value and the value for that field. When no such field, insert the default value or Null. Records are added at the end of the table.
can also use INSERT INTO statement to add a set of entries from another table or query using the SELECT ... FROM as shown above in the query syntax for adding multiple records. In this case the SELECT clause specifies the fields to be added in the specified target table.
to or from the table may specify a table or query.
If the target table contains a primary key, make sure it is unique, and non-Null values, if not, no records will be added. If you add records to a table of Incremental field, do not include incremental field in the query. You can use the clause to add records to a table in another database.
can find the records to be added to the query by first running a query
selection using the same selection criteria and see the result. Added a query copies the records from one or more tables in another. The tables containing the records to be added are not affected by the query of addition. Instead of adding records in another table, you can specify the values \u200b\u200bof each field in a new record using the VALUES clause. If you omit the field list, the VALUES clause must include a value for each field in the table, INSERT will fail otherwise.
INSERT INTO SELECT Customers .* FROM Clientes_Viejos Clientes_Nuevos;
INSERT INTO Employees (FirstnameLastname, Salary, Title)
VALUES ('Alberto Sanches', 12500, 'Manager') INSERT INTO
SELECT employees .* FROM Vendors Vendors
UPDATE WHERE Fecha_Contratacion <>
Create an update query that changes the values \u200b\u200bof the fields in a specified table based on specific criteria. Its syntax is: UPDATE Table SET
Field1 = Value1, Field2 = Value2, ... WHERE
Campon = valueN Criterion;
UPDATE
is especially useful when you want change a large number of records or when they are in multiple tables
. You can change several fields at once. The following example increases
Amount values \u200b\u200bby 15 percent and transport values \u200b\u200bat 5 percent for those that have been sent to the city of Cordoba.:
UPDATE Invoices SET Amount = Amount * 1.15, Transport = Transport * WHERE
5.1 CiudadEnvío = 'Cordoba';
UPDATE does not generate any results. To determine which records to change, we must first examine the results of a select query using the same criteria and then run the update query. UPDATE Employees SET
Organizational Chart WHERE = 5 = 2;
UPDATE Products SET Stock = Stock * 1.1 WHERE AND Family Provider = 8 = 3;
If an update query WHERE clause suppress all records in the table marked will be updated. UPDATE Employees SET
SalarioNeto = SalarioNeto * 1.1
Friday, July 11, 2008
Friday, July 4, 2008
Baby's Room Wood Paneling
Inflating Tires Save Gas New Auto
that
that
Today fuel is so expensive in the world not others know the following information.
These are simple tips to save gas:
- Use the vehicle only if necessary.
- accelerate smoothly, consuming accelerations.
- brake smoothly.
- not drive at high engine speed.
- if you go on the road or highway to save the ideal speed is 90 Km / H.
Subscribe to:
Posts (Atom)