forked from orientechnologies/orientdb
-
Notifications
You must be signed in to change notification settings - Fork 0
SQL Insert
lvca edited this page Dec 14, 2012
·
1 revision
The SQL Insert command creates a new record into the database. Records can be schema-less.
INSERT INTO <Class>|cluster:<cluster>|index:<index> [<cluster>](cluster) [VALUES (<expression>[,]((<field>[,]*))*)]|[<field> = <expression>[,](SET)*]
insert into Profile (name, surname) values ('Jay', 'Miner' )
insert into Profile SET name = 'Jay', surname = 'Miner'
insert into Profile cluster profile_recent (name, surname) values ('Jay', 'Miner' )
insert into Profile(name,surname) VALUES ('Jay','Miner'),('Frank','Hermier),('Emily','Saut')
insert into Employee (name, boss) values ('jack', #11:99 )
insert into Employee SET name = 'jack', boss = #11:99
insert into Profile (name, friends) values ('Luca', [#10:3, #10:4] )
insert into Profile SET name = 'Luca', friends = [#10:3, #10:4]
insert into Diver SET name = 'Luca', buddy = (select from Diver where name = 'Marko')
insert into Diver SET name = 'Luca', buddy = (insert into Diver name = 'Marko')
This inserts a new document in the cluster 'asiaemployee':
insert into cluster:asiaemployee (name) values ('Mattew')
But note that the document will have no class assigned. To create a document of a certain class but in a different cluster than the default one use:
insert into cluster:asiaemployee (@class, content) values('employee', 'Mattew')
That will insert the document of type 'employee' in the cluster 'asiaemployee'.
insert into Profile (name, address) values ('Luca', { "@type" : "d", "street" : "Melrose Avenue", "@version" : 0 } )
To know more about other SQL commands look at SQL commands.