官术网_书友最值得收藏!

Working with status updates

Now that we've got our status updates table ready, let's create our first status update:

INSERT INTO "user_status_updates" 
("username", "id", "body")
VALUES (
'alice',
76e7a4d0-e796-11e3-90ce-5f98e903bf02,
'Learning Cassandra!'
);

This will look pretty familiar; we specify the table we want to insert data into, the list of columns we're going to provide data for, and the values for these columns in the given order.

Let's give bob a status update too by inserting the following row in the user_status_updates table:

INSERT INTO "user_status_updates" 
("username", "id", "body")
VALUES (
'bob',
97719c50-e797-11e3-90ce-5f98e903bf02,
'Eating a tasty sandwich.'
);

Now we have two rows, each identified by the combination of the username and id columns. Let's take a look at the contents of our table using the following SELECT statement:

SELECT * FROM "user_status_updates";

We'll be able to see the two rows that we inserted, as follows:

Note that, as we saw in the users table, the rows are not returned in lexical order of username; indeed, they're in the same order as the user records themselves are. Recall from the Paginating through results section of Chapter 2, The First Table, that the username column is ordered by an internally generated token, which is deterministic but meaningless from the application's perspective.

主站蜘蛛池模板: 固始县| 枝江市| 全椒县| 图木舒克市| 拉孜县| 安宁市| 益阳市| 原阳县| 牡丹江市| 慈溪市| 淮北市| 大安市| 霍州市| 安乡县| 曲沃县| 天门市| 乌苏市| 通化县| 潮州市| 满洲里市| 黄大仙区| 镇平县| 三原县| 仙游县| 陆川县| 策勒县| 吴桥县| 长兴县| 东兴市| 澄城县| 广宗县| 绥德县| 清水县| 长海县| 新野县| 开封市| 闽侯县| 龙岩市| 福清市| 全椒县| 梨树县|