Knowledge

View (SQL)

Source đź“ť

1089: 1099: 36: 1109: 285:
on views. This technique allows the definition of other logic for execution in place of an insert, update, or delete operation on the views. Thus database systems can implement data modifications based on read-only views. However, an INSTEAD OF trigger does not change the read-only or updatable
240:
in a base table lack any defined ordering, rows available through a view do not appear with any default sorting. A view is a relational table, and the relational model defines a table as a set of rows. Since sets are not ordered — by definition — neither are the rows of a view.
177:
Views can represent a subset of the data contained in a table. Consequently, a view can limit the degree of exposure of the underlying tables to the outer world: a given user may have permission to query the view, while denied access to the rest of the base
249:) does not allow an ORDER BY clause in the subquery of a CREATE VIEW command, just as it is refused in a CREATE TABLE statement. However, sorted data can be obtained from a view, in the same way as any other table — as part of a query 617:
The optimizer then removes unnecessary fields and complexity (for example it is not necessary to read the address, since the parent invocation does not make use of it) and then sends the query to the SQL engine for processing.
277:
operations can be performed on updatable views. Read-only views do not support such operations because the DBMS cannot map the changes to the underlying base tables. A view update is done by key preservation.
265:
Views can be defined as read-only or updatable. If the database system can determine the reverse mapping from the view schema to the schema of the underlying base tables, then the view is updatable.
316:. They give a static snapshot of the data and may include data from remote sources. The accuracy of a materialized view depends on the frequency of trigger mechanisms behind its updates. 225:, so can a database view. In another parallel with functions, database users can manipulate nested views, thus one view can aggregate data from other views. Without the use of views, the 343:
A view is equivalent to its source query. When queries are run against views, the query is modified. For example, if there exists a view named accounts_view with the content as follows:
166:: as a result set, it is a virtual table computed or collated dynamically from data in the database when access to that view is requested. Changes applied to the data in a relevant 699: 682: 694: 1214: 1092: 1179: 765: 654: 210:
Views take very little space to store; the database contains only the definition of a view, not a copy of all the data that it presents.
119: 1149: 1112: 818: 1069: 1192: 716: 222: 57: 1008: 331:
introduced in its 2000 version indexed views which only store a separate index from the table, but not the entire data.
100: 1034: 753: 53: 72: 957: 947: 723: 301: 1044: 777: 203:
Views can hide the complexity of data. For example, a view could appear as Sales2020 or Sales2021, transparently
148:
that presents a limited perspective of the database to a user. This pre-established query command is kept in the
79: 1224: 1003: 993: 647: 250: 46: 706: 1074: 1029: 226: 86: 1049: 803: 1102: 1039: 921: 891: 760: 711: 627: 483:
The RDBMS then takes the simple query, replaces the equivalent view, then sends the following to the
328: 218: 204: 68: 1059: 952: 937: 864: 689: 159: 233:
would become much more difficult. Views can make it easier to create lossless join decomposition.
1054: 998: 967: 916: 748: 640: 230: 1161:
Views are stored queries that when invoked produce a result set. A view acts as a virtual table.
808: 1188: 874: 728: 309: 295: 1064: 911: 901: 869: 282: 972: 942: 896: 677: 484: 320: 254: 189: 163: 149: 1024: 962: 906: 879: 772: 733: 313: 242: 237: 145: 93: 1208: 1141: 843: 828: 1219: 274: 270: 266: 833: 813: 35: 213:
Views structure data in a way that classes of users find natural and intuitive.
977: 848: 823: 632: 332: 182: 154: 141: 17: 327:
provides so-called "materialized query tables" (MQTs) for the same purpose.
193: 838: 793: 663: 246: 133: 324: 197: 170:
are reflected in the data shown in subsequent invocations of the view.
743: 738: 798: 305: 245:
clause in the view definition is meaningless; the SQL standard (
200:, etc.) and presents the calculated results as part of the data. 636: 1173: 1171: 1169: 29: 185:
and simplify multiple tables into a single virtual table.
452:
then the application could run a simple query such as:
1017: 986: 930: 857: 786: 670: 335:implemented materialized views in its 9.3 release. 312:: pre-executed, non-virtual views commonly used in 60:. Unsourced material may be challenged and removed. 304:have extended the views from read-only subsets of 281:Some systems support the definition of INSTEAD OF 257:) do not abide by this SQL standard restriction. 253:on that view. Nevertheless, some DBMS (such as 188:Views can act as aggregated tables, where the 1136: 1134: 648: 8: 1178:Groff, James R.; Weinberg, Paul N. (1999). 655: 641: 633: 173:Views can provide advantages over tables: 1187:. Osborne/McGraw-Hill. pp. 291–292. 120:Learn how and when to remove this message 1130: 319:Materialized views were introduced by 7: 58:adding citations to reliable sources 1108: 162:, a view does not form part of the 25: 1107: 1097: 1088: 1087: 34: 27:Database stored query result set 1152:from the original on 2023-11-23 1098: 45:needs additional citations for 1: 286:property of the view itself. 261:Read-only vs. updatable views 221:(in programming) can provide 207:the actual underlying table. 1215:Database management systems 1181:SQL: The Complete Reference 664:Database management systems 302:database management systems 1241: 1070:Object–relational database 293: 1083: 1045:Federated database system 778:Blockchain-based database 489: 454: 345: 1148:. Oracle. 2023-12-12. 1075:Transaction processing 1030:Database normalization 973:Query rewriting system 492:-- Preprocessed query: 1050:Referential integrity 294:Further information: 1040:Distributed database 628:Bidirectionalization 329:Microsoft SQL Server 54:improve this article 1060:Relational calculus 938:Concurrency control 229:of databases above 160:relational database 1142:"25.5 Using Views" 1055:Relational algebra 999:Query optimization 804:Armstrong's axioms 495:------------------ 310:materialized views 290:Materialized views 231:second normal form 152:. Unlike ordinary 1121: 1120: 729:Wide-column store 724:Document-oriented 348:-- accounts_view: 296:Materialized view 192:aggregates data ( 130: 129: 122: 104: 16:(Redirected from 1232: 1199: 1198: 1186: 1175: 1164: 1163: 1158: 1157: 1138: 1111: 1110: 1101: 1100: 1091: 1090: 1065:Relational model 1035:Database storage 912:Stored procedure 657: 650: 643: 634: 613: 610: 607: 604: 601: 598: 595: 592: 589: 586: 583: 580: 577: 574: 571: 568: 565: 562: 559: 556: 553: 550: 547: 544: 541: 538: 535: 532: 529: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 479: 476: 473: 470: 467: 464: 461: 458: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 412: 409: 406: 403: 400: 397: 394: 391: 388: 385: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 314:data warehousing 168:underlying table 125: 118: 114: 111: 105: 103: 62: 38: 30: 21: 1240: 1239: 1235: 1234: 1233: 1231: 1230: 1229: 1225:Database theory 1205: 1204: 1203: 1202: 1195: 1184: 1177: 1176: 1167: 1155: 1153: 1140: 1139: 1132: 1127: 1122: 1117: 1079: 1025:Database models 1013: 982: 968:Query optimizer 943:Data dictionary 926: 897:Transaction log 853: 809:Codd's 12 rules 782: 712:Column-oriented 678:Object-oriented 666: 661: 624: 615: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 573:table_customers 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 485:query optimizer 481: 480: 477: 474: 471: 468: 465: 462: 459: 457:-- Simple query 456: 450: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 411:table_customers 410: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 356: 353: 350: 347: 341: 321:Oracle Database 308:, particularly 298: 292: 263: 255:Oracle Database 190:database engine 164:physical schema 150:data dictionary 126: 115: 109: 106: 69:"View" SQL 63: 61: 51: 39: 28: 23: 22: 15: 12: 11: 5: 1238: 1236: 1228: 1227: 1222: 1217: 1207: 1206: 1201: 1200: 1193: 1165: 1129: 1128: 1126: 1123: 1119: 1118: 1116: 1115: 1105: 1095: 1084: 1081: 1080: 1078: 1077: 1072: 1067: 1062: 1057: 1052: 1047: 1042: 1037: 1032: 1027: 1021: 1019: 1018:Related topics 1015: 1014: 1012: 1011: 1006: 1001: 996: 994:Administration 990: 988: 984: 983: 981: 980: 975: 970: 965: 963:Query language 960: 955: 950: 945: 940: 934: 932: 928: 927: 925: 924: 919: 914: 909: 904: 899: 894: 889: 884: 883: 882: 877: 872: 861: 859: 855: 854: 852: 851: 846: 841: 836: 831: 826: 821: 816: 811: 806: 801: 796: 790: 788: 784: 783: 781: 780: 775: 770: 769: 768: 758: 757: 756: 746: 741: 736: 731: 726: 721: 720: 719: 709: 704: 703: 702: 697: 687: 686: 685: 674: 672: 668: 667: 662: 660: 659: 652: 645: 637: 631: 630: 623: 620: 582:accounts_table 540:money_received 525:money_received 490: 455: 420:accounts_table 378:money_received 363:money_received 346: 340: 337: 291: 288: 262: 259: 241:Therefore, an 215: 214: 211: 208: 201: 186: 179: 128: 127: 42: 40: 33: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 1237: 1226: 1223: 1221: 1218: 1216: 1213: 1212: 1210: 1196: 1190: 1183: 1182: 1174: 1172: 1170: 1166: 1162: 1151: 1147: 1143: 1137: 1135: 1131: 1124: 1114: 1106: 1104: 1096: 1094: 1086: 1085: 1082: 1076: 1073: 1071: 1068: 1066: 1063: 1061: 1058: 1056: 1053: 1051: 1048: 1046: 1043: 1041: 1038: 1036: 1033: 1031: 1028: 1026: 1023: 1022: 1020: 1016: 1010: 1007: 1005: 1002: 1000: 997: 995: 992: 991: 989: 985: 979: 976: 974: 971: 969: 966: 964: 961: 959: 956: 954: 951: 949: 946: 944: 941: 939: 936: 935: 933: 929: 923: 920: 918: 915: 913: 910: 908: 905: 903: 900: 898: 895: 893: 890: 888: 885: 881: 878: 876: 873: 871: 868: 867: 866: 863: 862: 860: 856: 850: 847: 845: 844:Surrogate key 842: 840: 837: 835: 832: 830: 829:Candidate key 827: 825: 822: 820: 817: 815: 812: 810: 807: 805: 802: 800: 797: 795: 792: 791: 789: 785: 779: 776: 774: 771: 767: 764: 763: 762: 759: 755: 752: 751: 750: 747: 745: 742: 740: 737: 735: 732: 730: 727: 725: 722: 718: 715: 714: 713: 710: 708: 705: 701: 698: 696: 693: 692: 691: 688: 684: 681: 680: 679: 676: 675: 673: 669: 665: 658: 653: 651: 646: 644: 639: 638: 635: 629: 626: 625: 621: 619: 488: 486: 478:accounts_view 453: 351:------------- 344: 338: 336: 334: 330: 326: 322: 317: 315: 311: 307: 303: 297: 289: 287: 284: 279: 276: 272: 268: 260: 258: 256: 252: 248: 244: 239: 234: 232: 228: 227:normalization 224: 220: 212: 209: 206: 202: 199: 195: 191: 187: 184: 180: 176: 175: 174: 171: 169: 165: 161: 157: 156: 151: 147: 143: 139: 135: 124: 121: 113: 110:December 2023 102: 99: 95: 92: 88: 85: 81: 78: 74: 71: â€“  70: 66: 65:Find sources: 59: 55: 49: 48: 43:This article 41: 37: 32: 31: 19: 18:Database view 1180: 1160: 1154:. Retrieved 1145: 886: 616: 482: 460:------------ 451: 342: 318: 299: 280: 264: 235: 216: 205:partitioning 172: 167: 153: 144:of a stored 137: 131: 116: 107: 97: 90: 83: 76: 64: 52:Please help 47:verification 44: 1113:WikiProject 1004:Replication 892:Transaction 834:Foreign key 814:CAP theorem 761:Multi-model 609:customer_id 597:customer_id 447:customer_id 435:customer_id 339:Equivalence 223:abstraction 155:base tables 1209:Categories 1194:0072118458 1156:2023-12-12 1125:References 978:Query plan 931:Components 849:Unique key 766:comparison 700:comparison 690:Relational 683:comparison 546:money_sent 531:money_sent 384:money_sent 369:money_sent 333:PostgreSQL 217:Just as a 181:Views can 142:result set 80:newspapers 987:Functions 922:Partition 749:In-memory 707:Key–value 251:statement 1150:Archived 1093:Category 1009:Sharding 865:Relation 839:Superkey 794:Database 787:Concepts 622:See also 323:, while 300:Various 283:triggers 247:SQL:2003 243:ORDER BY 236:Just as 219:function 134:database 1103:Outline 902:Trigger 858:Objects 561:address 555:balance 507:balance 472:balance 399:address 393:balance 325:IBM Db2 198:average 140:is the 94:scholar 1191:  917:Cursor 875:column 744:NewSQL 516:SELECT 498:SELECT 463:SELECT 354:SELECT 275:DELETE 273:, and 271:UPDATE 267:INSERT 178:table. 96:  89:  82:  75:  67:  1185:(PDF) 1146:MySQL 907:Index 870:table 773:Cloud 739:NoSQL 734:Graph 671:Types 158:in a 146:query 132:In a 101:JSTOR 87:books 1189:ISBN 958:ODBC 948:JDBC 887:View 824:Null 819:CRUD 799:ACID 754:list 717:list 695:list 579:JOIN 570:FROM 519:name 510:FROM 501:name 475:FROM 466:name 417:JOIN 408:FROM 357:name 306:data 238:rows 183:join 138:view 136:, a 73:news 1220:SQL 953:XQJ 880:row 567:... 405:... 194:sum 56:by 1211:: 1168:^ 1159:. 1144:. 1133:^ 588:ON 552:AS 487:: 426:ON 390:AS 269:, 196:, 1197:. 656:e 649:t 642:v 612:) 606:. 603:c 600:= 594:. 591:a 585:a 576:c 564:, 558:, 549:) 543:- 537:( 534:, 528:, 522:, 513:( 504:, 469:, 444:. 441:c 438:= 432:. 429:a 423:a 414:c 402:, 396:, 387:) 381:- 375:( 372:, 366:, 360:, 123:) 117:( 112:) 108:( 98:· 91:· 84:· 77:· 50:. 20:)

Index

Database view

verification
improve this article
adding citations to reliable sources
"View" SQL
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
database
result set
query
data dictionary
base tables
relational database
physical schema
join
database engine
sum
average
partitioning
function
abstraction
normalization
second normal form
rows
ORDER BY

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

↑