Questions tagged [dml]

Data Manipulation Language(DML) is database syntax used for SQL commands, including the INSERT, UPDATE, and DELETE statements. DML triggers operate on INSERT, UPDATE, and DELETE statements, and help to enforce business rules and extend data integrity when data is modified in tables or views.

A data manipulation language (DML) is a family of syntax elements similar to a computer programming language used for inserting, deleting and updating data in a database. Performing read-only queries of data is sometimes also considered a component of DML.

A popular data manipulation language is that of Structured Query Language (SQL), which is used to retrieve and manipulate data in a relational database. Other forms of DML are those used by IMS/DLI, CODASYL databases, such as IDMS and others.

References:

DML related tags

539 questions
4222
votes
38 answers

How do I UPDATE from a SELECT in SQL Server?

In SQL Server, it is possible to insert rows into a table with an INSERT.. SELECT statement: INSERT INTO Table (col1, col2, col3) SELECT col1, col2, col3 FROM other_table WHERE sql = 'cool' Is it also possible to update a table with SELECT? I…
jamesmhaley
  • 44,484
  • 11
  • 36
  • 49
833
votes
15 answers

How to truncate a foreign key constrained table?

Why doesn't a TRUNCATE on mygroup work? Even though I have ON DELETE CASCADE SET I get: ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (mytest.instance, CONSTRAINT instance_ibfk_1 FOREIGN KEY (GroupID) REFERENCES…
user391986
  • 29,536
  • 39
  • 126
  • 205
502
votes
13 answers

What are DDL and DML?

I have heard the terms DDL and DML in reference to databases, but I don't understand what they are. What are they and how do they relate to SQL?
Sachindra
  • 6,421
  • 6
  • 29
  • 38
19
votes
2 answers

Combine stored procedure and query in T-SQL

How do I combine executing of a stored procedure and using its result or parameters in a regular SQL query? For example I would like to do something like the following: -- passing result of SELECT to SP SELECT a, b FROM t EXEC my_sp a, b --…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
15
votes
3 answers

MySQL 5.5 add foreign key fails with errors [HY000][150] and [HY000][1005]

I have tried adding a foreign key like this... ALTER TABLE OrderLineItem ADD CONSTRAINT FK_OrderLineItem_ShippingType_name FOREIGN KEY (shippingType) REFERENCES ShippingType(name); Or like this in Mysql 5.5... alter table OrderLineItem add…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
11
votes
3 answers

Selecting all columns and constant value from Oracle table

How can I select all columns and add a column with a constant value in Oracle? With MS SQL Server, I can use: Select *,5 From TableA; I will get this: column1 column2 5 xx xx 5 xx xx 5
CooperMAN
  • 111
  • 1
  • 1
  • 3
11
votes
3 answers

hibernate update single column using criteria

I have a table that contains mamy columns and I want to update the one or few columns of the row without effecting remaining columns I can write query: update table as t set t.a=:a set t.b=:b where t.id=1 But seen I dont know which columns will be…
11
votes
3 answers

MySQL 5.5.30 cascaded triggers not working

For some reason, on a MySQL 5.5.30 machine, a trigger which deletes a row from a second table does no longer fire the delete trigger on the second table. This works perfectly on our local MySQL version 5.5.25 I did not find any documentation that…
Michel Feldheim
  • 17,625
  • 5
  • 60
  • 77
11
votes
5 answers

PostgreSQL 8.4 grant DML privileges on all tables to a role

How do I go about granting DML (SELECT,INSERT,UPDATE,DELETE) on all tables in a schema in PostgreSQL 8.4? I'd also like this grant to persist for new table creation in the future as well. I've seen solutions for 9.0 but I'm stuck with 8.4 as it…
pointyhat
  • 167
  • 1
  • 1
  • 10
9
votes
2 answers

How to copy an inserted,updated,deleted row in a SQL Server trigger(s)

If a user changes table HelloWorlds, then I want 'action they did', time they did it, and a copy of the original row insert into HelloWorldsHistory. I would prefer to avoid a separate triggers for insert, update, and delete actions due to the column…
DefyGravity
  • 5,681
  • 5
  • 32
  • 47
8
votes
3 answers

TSQL 2005, XML DML - Update Two Values at once?

Is there any way to combine these two replace values with 1 update statement? UPDATE dbo.MyTable SET MyXmlColumn.modify('replace value of (/node/@att1)[1] with "1"') WHERE id = 1 UPDATE dbo.MyTable SET MyXmlColumn.modify('replace value of…
TrevDev
  • 1,106
  • 11
  • 24
8
votes
1 answer

What are the origins of terms DDL, DML and DCL?

I'm familiar with the definitions of DDL, DML, and DCL as applied to SQL. There are lots of web sites and books that define and explain them. But no one seems to give an authoritative reference. I'm interested in the origin of these terms. Did SQL…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
8
votes
2 answers

The Fastest Way to Load an Array DML in Delphi FireDAC

I am using Delphi XE8 with FireDAC to load a large SQLite database. To do so, I'm using the Array DML execution technique to efficiently insert a large number of records at once, like this: FDQueryAddINDI.SQL.Text := 'insert into indi values (' +…
lkessler
  • 19,819
  • 36
  • 132
  • 203
8
votes
5 answers

SQL Server Trigger switching Insert,Delete,Update

Hello is possible to switch between DML commands/operations (Insert,Delete,Update) on Trigger Body?, I try to snippet some T-SQL for understand me better : CREATE TRIGGER DML_ON_TABLEA ON TABLEA AFTER INSERT,DELETE,UPDATE AS BEGIN SET…
Jonathan Escobedo
  • 3,977
  • 12
  • 69
  • 90
7
votes
1 answer

Why does MVCC require locking for DML statements

In PostgreSQL, the MVCC concurrency control mechanism says that: MVCC locks acquired for querying (reading) data do not conflict with locks acquired for writing data, and so reading never blocks writing and writing never blocks reading So,…
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
1
2 3
35 36