# Query: travel-sample # Flags: WordMatch RegExp # Including: ./docs-server # Excluding: *.html,*.json N1QL Data Manipulation Language modules/n1ql/pages/n1ql-language-reference/delete.adoc: 156: This example requires the _Query Delete_ privilege on `pass:c[`travel-sample`]`. 160: DELETE FROM `travel-sample` WHERE type = "hotel"; 167: This example requires the _Query Delete_ privilege on `pass:c[`travel-sample`]` and the _Query Select_ privilege on `pass:c[`beer-sample`]`. 171: DELETE FROM `travel-sample` WHERE city 175: This example requires the _Query Delete_ and _Query Select_ privileges on `pass:c[`travel-sample`]`. 179: DELETE FROM `travel-sample` 180: WHERE city = (SELECT MAX(city) FROM `travel-sample`) 187: These examples require the _Query Delete_ and _Query Select_ privileges on `pass:c[`travel-sample`]`. 191: DELETE FROM `travel-sample` WHERE type = "hotel" RETURNING *; 196: DELETE FROM `travel-sample` modules/n1ql/pages/n1ql-language-reference/insert.adoc: 41: Install the sample bucket `travel-sample` before proceeding to run the examples in this topic. 42: See {install-sample-buckets}[Sample Buckets] for information on how to install the sample buckets and {datamodel}[Travel App Data Model] for details about the travel-sample data model. 73: * To execute the following statement, user must have the _Query Insert_ privilege on `pass:c[`travel-sample`]`. 77: INSERT INTO `travel-sample` (KEY, VALUE) 81: * To execute the following statement, user must have the _Query Insert_ privilege on `pass:c[`travel-sample`]` and the _Query Select_ privilege on `pass:c[`travel-sample`]`. 85: INSERT INTO `travel-sample` (KEY, VALUE) 89: * To execute the following statement, user must have the _Query Insert_ privilege on `pass:c[`travel-sample`]` and _Query Select_ privilege on `pass:c[`beer-sample`]`. 93: INSERT INTO `travel-sample` (KEY foo, VALUE bar) 97: * To execute the following statement, user must have the _Query Insert_ privilege on `pass:c[`travel-sample`]` and _Query Select_ privilege on `pass:c[`travel-sample`]`. 101: INSERT INTO `travel-sample` (KEY foo, VALUE bar) 102: SELECT "foo" || meta().id, bar FROM `travel-sample` WHERE type = "hotel" 224: INSERT INTO `travel-sample` ( KEY, VALUE ) 239: INSERT INTO `travel-sample` ( KEY, VALUE ) 254: INSERT INTO `travel-sample` (KEY, VALUE) 293: INSERT INTO `travel-sample` (KEY, VALUE) 306: "travel-sample": { 322: INSERT INTO `travel-sample` (KEY, VALUE) 335: "travel-sample": { 350: INSERT INTO `travel-sample` (KEY, VALUE) 360: Insert a document into the `travel-sample` keyspace using an expiration of 5 days. 365: INSERT INTO `travel-sample` (KEY, VALUE, OPTIONS) 415: Query the `travel-sample` keyspace for documents of `type` "airport" and `airportname` "Heathrow", and then insert the projection (1 document) into the `travel-sample` keyspace using a unique key generated using `UUID()`. 420: INSERT INTO `travel-sample` (KEY UUID(), VALUE _airport) 421: SELECT _airport FROM `travel-sample` _airport 431: "travel-sample": { 454: Query the `travel-sample` keyspace for documents of `type` "airport" and `airportname` "Heathrow", and then insert the projection into the `travel-sample` keyspace using a unique key and an expiration of 2 hours. 459: INSERT INTO `travel-sample` (KEY UUID(), VALUE doc, OPTIONS {"expiration": 2*60*60}) 460: SELECT a AS doc FROM `travel-sample` a 473: INSERT INTO `travel-sample` (KEY UUID(), VALUE doc, OPTIONS {"expiration": ttl}) 474: SELECT META(a).expiration AS ttl, a AS doc FROM `travel-sample` a 512: INSERT INTO `travel-sample` (KEY, VALUE) 540: INSERT INTO `travel-sample` (KEY, VALUE) 662: The following statement inserts a single JSON document into the `travel-sample` keyspace with key "k001". 668: INSERT INTO `travel-sample` ( KEY, VALUE ) 689: "travel-sample": { 712: Insert a new document with `key` "1025" and `type` "airline" into the `travel-sample` keyspace. 717: INSERT INTO `travel-sample` (KEY,VALUE) 740: "travel-sample": { 769: Insert two documents with `key` "airline_4444" and "airline_4445" of `type` "airline" into the `travel-sample` keyspace: 774: INSERT INTO `travel-sample` (KEY,VALUE) 804: "travel-sample": { 815: "travel-sample": { 843: Query the `travel-sample` keyspace for documents where the `airportname` is "Heathrow" and `type` is "airport". 844: Then insert the result of the select statement (a well-formed JSON document) into the `travel-sample` keyspace with a key generated using the `UUID()` function. 849: INSERT INTO `travel-sample` (KEY UUID(), VALUE _airport) 850: SELECT _airport FROM `travel-sample` _airport 879: INSERT INTO `travel-sample` (KEY k1||"::"||clock_str(), value t) 881: FROM `travel-sample` t 894: "travel-sample": { 912: "travel-sample": { 957: INSERT INTO `travel-sample` (KEY UUID()) -- <3> 959: FROM `travel-sample` x 962: FROM `travel-sample` t 979: "travel-sample": { 986: "travel-sample": { 993: "travel-sample": { 1000: "travel-sample": { 1024: INSERT INTO `travel-sample` (KEY, VALUE) 1048: "travel-sample": { 1080: INSERT INTO `travel-sample` (KEY, VALUE) 1141: "travel-sample": { 1185: EXPLAIN INSERT INTO `travel-sample` (KEY,VALUE) 1223: "alias": "travel-sample", 1224: "keyspace": "travel-sample", 1245: "text": "INSERT INTO `travel-sample` (KEY,VALUE) VALUES ( \"1025\", { \"callsign\": \"SKY-AIR\", \"country\": \"United States\", \"id\": \"1025\", \"type\": \"airline\"} ), VALUES ( \"1026\", { \"callsign\": \"F1-AIR\", \"country\": \"United States\", \"id\": \"1014\"} ) RETURNING *" 1266: EXPLAIN INSERT INTO `travel-sample` (key UUID(), value _airport) 1267: SELECT _airport FROM `travel-sample` _airport 1293: "keyspace": "travel-sample", 1317: "keyspace": "travel-sample", 1338: "keyspace": "travel-sample", 1373: "alias": "travel-sample", 1375: "keyspace": "travel-sample", 1387: "text": "INSERT INTO `travel-sample` (KEY UUID(), VALUE _airport)\n SELECT _airport FROM `travel-sample` _airport\n WHERE type = \"airport\" AND airportname = \"Heathrow\";" 1392: The Query Engine first executes the `SELECT` statement and then uses the projection to insert into the `travel-sample` keyspace, performing the operations in the order listed: 1398: <5> An `Insert` of the value along with the auto-generated key into the `travel-sample` keyspace. modules/n1ql/pages/n1ql-language-reference/merge.adoc: 637: MERGE INTO `travel-sample` t 658: MERGE INTO `travel-sample` AS route 659: USING `travel-sample` AS airport 674: This example compares a source set of airport data with the `travel-sample` airport data. 675: If the airport already exists in `travel-sample`, the record is updated. 676: If the airport does not exist in `travel-sample`, a new record is created. 680: MERGE INTO `travel-sample` AS target 702: This example compares a source set of airport data with the `travel-sample` airport data. 703: If the airport already exists in `travel-sample`, the record is updated, and the existing document expiration is preserved. 704: If the airport does not exist in `travel-sample`, a new record is created with an expiration of one week. 708: MERGE INTO `travel-sample` AS target 735: MERGE INTO `travel-sample` t modules/n1ql/pages/n1ql-language-reference/update.adoc: 31: * To execute the following statement, user must have the _Query Update_ privilege on `pass:c[`travel-sample`]`. 35: UPDATE `travel-sample` SET foo = 5 38: * To execute the following statement, user must have the _Query Update_ privilege on the `pass:c[`travel-sample`]` and _Query Select_ privilege on `pass:c[`beer-sample`]`. 42: UPDATE `travel-sample` 47: * To execute the following statement, user must have the _Query Update_ privilege on `pass:c[`travel-sample`]` and _Query Select_ privilege on `pass:c[`travel-sample`]`. 51: UPDATE `travel-sample` 244: UPDATE `travel-sample` USE KEYS "landmark_10090" SET nickname = "Squiggly Bridge" RETURNING `travel-sample`.nickname; 260: This statement removes the `nickname` attribute from the `travel-sample` keyspace for the document with the key `landmark_10090`. 264: UPDATE `travel-sample` USE KEYS "landmark_10090" UNSET nickname RETURNING `travel-sample`.name; 280: This statement sets the `codeshare` attribute for each element in the `schedule` array for document `route_10003` in the `travel-sample` keyspace. 284: UPDATE `travel-sample` t USE KEYS "route_10003" SET s.codeshare = NULL FOR s IN schedule END RETURNING t; 327: UPDATE `travel-sample` AS h USE KEYS "hotel_10025" 369: UPDATE `travel-sample` AS h USE KEYS "hotel_10025" 412: UPDATE `travel-sample` AS a 415: FROM `travel-sample` AS h 465: UPDATE `travel-sample` t USE KEYS "route_10003" 477: UPDATE `travel-sample` t USE KEYS "route_10003" 492: UPDATE `travel-sample` t USE KEYS "route_10003" 502: UPDATE `travel-sample` t USE KEYS "route_10003" modules/n1ql/pages/n1ql-language-reference/upsert.adoc: 36: * To execute the following statement, user must have the _Query Update_ and _Query Insert_ privileges on `pass:c[`travel-sample`]`. 40: UPSERT INTO `travel-sample` (KEY, VALUE) 44: * To execute the following statement, user must have the _Query Update_ and _Query Insert_ privileges on the `pass:c[`travel-sample`]` bucket and _Query Select_ privilege on `pass:c[`travel-sample`]` (for RETURNING clause). 48: UPSERT INTO `travel-sample` (KEY, VALUE) 53: * To execute the following statement, user must have the _Query Update_ and _Query Insert_ privileges on the `pass:c[`travel-sample`]` bucket and _Query Select_ privilege on `pass:c[`beer-sample`]`. 57: UPSERT INTO `travel-sample` (KEY foo, VALUE bar) 201: The following statement upserts documents with type [.in]`landmark-pub` into the [.in]`travel-sample` namespace. 206: UPSERT INTO `travel-sample` (KEY, VALUE)