forked from crate/crate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.txt
More file actions
87 lines (65 loc) · 2.85 KB
/
Copy pathhello.txt
File metadata and controls
87 lines (65 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.. highlight:: sh
===========
Hello Crate
===========
To get started let's have a quick look on how Crate can be used.
This tutorial uses the ``crash`` command-line SQL_ shell shipped with
the Crate distribution.
::
sh$ ./bin/crash
.. highlight:: psql
First let's connect to a running node::
cr> connect 127.0.0.1:4200;
+------------------------+-----------+---------+-----------+---------+
| server_url | node_name | version | connected | message |
+------------------------+-----------+---------+-----------+---------+
| http://127.0.0.1:... | crate | ... | TRUE | OK |
+------------------------+-----------+---------+-----------+---------+
CONNECT OK
In this guide we want to create a database for Twitter_ tweets. Let's create
the table ``tweets`` with all columns we need::
cr> create table tweets (
... created_at timestamp,
... id string primary key,
... retweeted boolean,
... source string INDEX using fulltext,
... text string INDEX using fulltext,
... user_id string
... );
CREATE OK (... sec)
Now we are ready to insert our first tweet::
cr> insert into tweets
... values (1394182937, '1', true, 'web', 'Don''t panic', 'Douglas');
INSERT OK, 1 row affected (... sec)
And another::
cr> insert into tweets
... values (
... 1394182938,
... '2',
... true,
... 'web',
... 'Time is an illusion. Lunchtime doubly so',
... 'Ford'
... );
INSERT OK, 1 row affected (... sec)
In order to query the inserted tweets the ``SELECT`` statement can be used.
Here it is used with a filter to only lookup Ford's tweets::
cr> select * from tweets where id = '2';
+------------+----+-----------+--------+-------------------------...-+---------+
| created_at | id | retweeted | source | text | user_id |
+------------+----+-----------+--------+-------------------------...-+---------+
| 1394182938 | 2 | TRUE | web | Time is an illusion. Lun... | Ford |
+------------+----+-----------+--------+-------------------------...-+---------+
SELECT 1 row in set (... sec)
.. seealso::
:doc:`Data Definition <sql/ddl>` - To see what options the create table
statement supports and to learn more about sharding and replication.
:doc:`Data Manipulation <sql/dml>` - In order to learn how to import, export,
insert, update or delete records.
:doc:`Querying Crate <sql/dql>` - Filtering, ordering, grouping and powerful
fulltext search. Learn how to find your data.
:doc:`Configuration <configuration>` - After you're done trying out Crate and
before you go into production you should take a look at this section.
Especially the `CRATE_HEAP_SIZE` environment variable is very important!
.. _SQL: https://en.wikipedia.org/wiki/SQL
.. _Twitter: https://twitter.com