Knowledge (XXG)

Delete (SQL)

Source 📝

32: 703:
Transaction log - DELETE needs to read records, check constraints, update block, update indexes, and generate redo / undo. All of this takes time, hence it takes time much longer than with TRUNCATE
375:
Suppose there is a simple database that lists people and addresses. More than one person can live at a particular address and a person can live at more than one address (this is an example of a
527:
table relates the person and address tables, showing that Joe, Bob and Ann all live at 2001 Main Street, but Joe also takes up residence on Pico Boulevard.
42: 593:. It could be that beyond just having three tables, the database also has been set up with a trigger so that whenever a row is deleted from 735:
command that works a lot quicker, as it only alters metadata and typically does not spend time enforcing constraints or firing triggers.
673:
It is a DML (Data Manipulation Language) command, therefore the following commands are used for this command: COMMIT and ROLLBACK
57: 804: 100: 141:, allow deletion of rows from multiple tables with one DELETE statement (this is sometimes called multi-table DELETE). 72: 79: 376: 776: 676:
Deletes all or some records from the table, you can limit the records to be deleted by using the WHERE clause
86: 20: 1128: 980: 68: 1008: 1072: 1067: 1051: 133:. A subset may be defined for deletion using a condition, otherwise all records are removed. Some 887: 797: 158: 837: 832: 130: 93: 1001: 931: 732: 150: 706:
reduces performance during execution - each record in the table is locked for deletion
1122: 1046: 987: 1097: 1015: 994: 945: 938: 910: 790: 1022: 959: 896: 31: 759: 1029: 966: 952: 924: 903: 739: 679:
Does not free the space occupied by the data in the table (in the TABLESPACE)
688:
You can undo the operation of removing records by using the ROLLBACK command
585:
To maintain referential integrity, Joe's records must be removed from both
973: 877: 872: 867: 862: 857: 852: 847: 134: 530:
In order to remove joe from the database, two deletes must be executed:
1107: 1102: 1092: 1087: 1082: 1077: 842: 827: 715:
DELETE generates a small amount of redo and a large amount of undo
138: 49: 738:
DELETE only deletes the rows. For deleting a table entirely the
728: 727:
Deleting all rows from a table can be very time-consuming. Some
786: 813: 709:
DELETE uses more transaction space than the TRUNCATE statement
122: 25: 718:
DELETE operation does not make unusable indexes usable again
1103:
SQL Routines and Types for the Java Programming Language
682:
Does not reset the SEQUENCE value assigned to the table
129:
statement is used to remove one or more records from a
53: 782: 1060: 1039: 886: 820: 471: 438: 397: 697:DELETE can be used in the case of: database link 798: 19:"DELETE" redirects here. For other uses, see 8: 779:gives examples of DELETE statements features 700:DELETE returns the number of records deleted 58:introducing citations to additional sources 121:In the database structured query language ( 805: 791: 783: 265:using a subquery in the where condition: 48:Relevant discussion may be found on the 751: 379:). The database only has three tables, 685:DELETE works much slower than TRUNCATE 597:any linked rows would be deleted from 712:DELETE can be used with indexed views 16:SQL database query language statement 7: 691:DELETE requires a shared table lock 1098:Information and Definition Schemas 14: 777:Truncate vs Delete SQL Databases 41:relies largely or entirely on a 30: 1: 601:. Then the first statement: 1088:Management of External Data 391:, with the following data: 371:Example with related tables 135:database management systems 1145: 1108:XML-Related Specifications 395: 18: 1083:Persistent Stored Modules 377:many-to-many relationship 1093:Object Language Bindings 638: 603: 532: 314: 312:using a list of values: 267: 244: 209: 191:'Lemon Meringue' 170: 760:"SQL Delete Statement" 742:command can be used. 238:Delete all rows from 1078:Call-Level Interface 636:trigger the second: 207:is smaller than 80. 54:improve this article 1052:Relational database 474: 441: 400: 472: 439: 398: 203:, if the value of 1116: 1115: 1061:ISO/IEC SQL parts 521: 520: 517: 516: 468: 467: 435: 434: 308:Delete rows from 261:Delete rows from 119: 118: 104: 69:"Delete" SQL 1136: 1032: 1025: 1018: 1011: 1004: 997: 990: 983: 976: 969: 962: 955: 948: 941: 934: 927: 920: 913: 906: 899: 807: 800: 793: 784: 764: 763: 762:. w3schools.com. 756: 723:Related commands 663: 660: 657: 654: 651: 648: 645: 642: 628: 625: 622: 619: 616: 613: 610: 607: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 475: 442: 401: 394: 393: 366: 363: 360: 357: 354: 351: 348: 345: 342: 339: 336: 333: 330: 327: 324: 321: 318: 304: 301: 298: 295: 292: 289: 286: 283: 280: 277: 274: 271: 257: 254: 251: 248: 234: 231: 228: 225: 222: 219: 216: 213: 195: 192: 189: 186: 183: 180: 177: 174: 114: 111: 105: 103: 62: 34: 26: 1144: 1143: 1139: 1138: 1137: 1135: 1134: 1133: 1119: 1118: 1117: 1112: 1056: 1035: 1028: 1021: 1014: 1007: 1000: 993: 986: 979: 972: 965: 958: 951: 944: 937: 930: 923: 916: 909: 902: 895: 882: 816: 811: 773: 768: 767: 758: 757: 753: 748: 725: 670: 665: 664: 661: 658: 655: 652: 649: 646: 643: 640: 630: 629: 626: 623: 620: 617: 614: 611: 608: 605: 583: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 373: 368: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 331: 328: 325: 322: 319: 316: 306: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 259: 258: 255: 252: 249: 246: 236: 235: 232: 229: 226: 223: 220: 217: 214: 211: 199:Delete rows in 197: 196: 193: 190: 187: 184: 181: 178: 175: 172: 147: 115: 109: 106: 63: 61: 47: 35: 24: 17: 12: 11: 5: 1142: 1140: 1132: 1131: 1121: 1120: 1114: 1113: 1111: 1110: 1105: 1100: 1095: 1090: 1085: 1080: 1075: 1070: 1064: 1062: 1058: 1057: 1055: 1054: 1049: 1043: 1041: 1037: 1036: 1034: 1033: 1026: 1019: 1012: 1005: 998: 991: 984: 977: 970: 963: 956: 949: 942: 935: 928: 921: 914: 907: 900: 892: 890: 884: 883: 881: 880: 875: 870: 865: 860: 855: 850: 845: 840: 835: 830: 824: 822: 818: 817: 812: 810: 809: 802: 795: 787: 781: 780: 772: 771:External links 769: 766: 765: 750: 749: 747: 744: 733:TRUNCATE TABLE 724: 721: 720: 719: 716: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 674: 669: 666: 639: 604: 533: 519: 518: 515: 514: 511: 507: 506: 503: 499: 498: 495: 491: 490: 487: 483: 482: 479: 469: 466: 465: 464:35 Pico Blvd. 462: 458: 457: 456:2001 Main St. 454: 450: 449: 446: 436: 433: 432: 429: 425: 424: 421: 417: 416: 413: 409: 408: 405: 372: 369: 315: 268: 245: 210: 171: 166:Lemon Meringue 146: 143: 137:(DBMSs), like 117: 116: 110:September 2019 52:. Please help 38: 36: 29: 15: 13: 10: 9: 6: 4: 3: 2: 1141: 1130: 1127: 1126: 1124: 1109: 1106: 1104: 1101: 1099: 1096: 1094: 1091: 1089: 1086: 1084: 1081: 1079: 1076: 1074: 1071: 1069: 1066: 1065: 1063: 1059: 1053: 1050: 1048: 1045: 1044: 1042: 1038: 1031: 1027: 1024: 1020: 1017: 1013: 1010: 1006: 1003: 999: 996: 992: 989: 985: 982: 978: 975: 971: 968: 964: 961: 957: 954: 950: 947: 943: 940: 936: 933: 929: 926: 922: 919: 915: 912: 908: 905: 901: 898: 894: 893: 891: 889: 885: 879: 876: 874: 871: 869: 866: 864: 861: 859: 856: 854: 851: 849: 846: 844: 841: 839: 836: 834: 831: 829: 826: 825: 823: 819: 815: 808: 803: 801: 796: 794: 789: 788: 785: 778: 775: 774: 770: 761: 755: 752: 745: 743: 741: 736: 734: 730: 722: 717: 714: 711: 708: 705: 702: 699: 696: 694:Triggers fire 693: 690: 687: 684: 681: 678: 675: 672: 671: 667: 637: 635: 634:automatically 602: 600: 596: 592: 588: 531: 528: 526: 512: 509: 508: 504: 501: 500: 496: 493: 492: 488: 485: 484: 480: 477: 476: 470: 463: 460: 459: 455: 452: 451: 447: 444: 443: 437: 430: 427: 426: 422: 419: 418: 414: 411: 410: 406: 403: 402: 396: 392: 390: 386: 382: 378: 370: 313: 311: 266: 264: 243: 241: 208: 206: 202: 169: 167: 163: 160: 156: 152: 144: 142: 140: 136: 132: 128: 124: 113: 102: 99: 95: 92: 88: 85: 81: 78: 74: 71: –  70: 66: 65:Find sources: 59: 55: 51: 45: 44: 43:single source 39:This article 37: 33: 28: 27: 22: 1129:SQL keywords 917: 754: 737: 726: 633: 631: 598: 594: 590: 586: 584: 529: 524: 522: 448:description 388: 384: 380: 374: 309: 307: 262: 260: 239: 237: 204: 200: 198: 165: 161: 154: 148: 126: 120: 107: 97: 90: 83: 76: 64: 40: 153:from table 1073:Foundation 1047:Edgar Codd 746:References 80:newspapers 1068:Framework 50:talk page 1123:Category 1002:Truncate 974:Order by 932:Group by 888:Keywords 878:SQL:2023 873:SQL:2016 868:SQL:2011 863:SQL:2008 858:SQL:2006 853:SQL:2003 848:SQL:1999 821:Versions 731:offer a 668:Features 440:address 300:mytable2 145:Examples 1040:Related 988:Prepare 399:person 385:address 323:mytable 310:mytable 276:mytable 263:mytable 253:mytable 240:mytable 164:equals 149:Delete 125:), the 94:scholar 1016:Update 995:Select 946:Insert 939:Having 918:Delete 911:Create 843:SQL-92 838:SQL-89 833:SQL-86 828:SEQUEL 641:DELETE 632:would 612:person 606:DELETE 595:person 587:person 559:DELETE 541:person 535:DELETE 387:, and 381:person 362:value5 356:value4 350:value3 344:value2 338:value1 317:DELETE 291:SELECT 270:DELETE 247:DELETE 224:height 212:DELETE 205:height 185:flavor 173:DELETE 162:flavor 159:column 157:where 127:DELETE 96:  89:  82:  75:  67:  21:Delete 1023:Where 1009:Union 960:Merge 650:WHERE 615:WHERE 568:WHERE 544:WHERE 407:name 326:WHERE 279:WHERE 221:WHERE 218:trees 201:trees 182:WHERE 139:MySQL 131:table 101:JSTOR 87:books 1030:With 981:Over 967:Null 953:Join 925:From 904:Case 740:DROP 729:DBMS 644:FROM 609:FROM 589:and 562:FROM 538:FROM 523:The 513:200 505:100 497:100 489:100 481:aid 478:pid 445:aid 431:Ann 423:Bob 415:Joe 404:pid 320:FROM 297:FROM 273:FROM 250:FROM 227:< 215:FROM 179:pies 176:FROM 155:pies 151:rows 73:news 814:SQL 653:pid 618:pid 571:pid 547:pid 473:pa 461:200 453:100 123:SQL 56:by 1125:: 897:As 647:pa 599:pa 591:pa 565:pa 525:pa 389:pa 383:, 365:); 332:IN 329:id 303:); 294:id 285:IN 282:id 242:: 230:80 168:: 806:e 799:t 792:v 662:; 659:1 656:= 627:; 624:1 621:= 580:; 577:1 574:= 556:; 553:1 550:= 510:1 502:3 494:2 486:1 428:3 420:2 412:1 359:, 353:, 347:, 341:, 335:( 288:( 256:; 233:; 194:; 188:= 112:) 108:( 98:· 91:· 84:· 77:· 60:. 46:. 23:.

Index

Delete

single source
talk page
improve this article
introducing citations to additional sources
"Delete" SQL
news
newspapers
books
scholar
JSTOR
SQL
table
database management systems
MySQL
rows
column
many-to-many relationship
DBMS
TRUNCATE TABLE
DROP
"SQL Delete Statement"
Truncate vs Delete SQL Databases
v
t
e
SQL
SEQUEL
SQL-86

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.