Hi,
Please take a look at the documentation of the CREATE TABLE [1]
Use:
CREATE TABLE tableName (id LONG PRIMARY KEY, name VARCHAR)
WITH "|CACHE_NAME=|cacheName"
Please pay attention to other options. Its may be useful to use cache
API & SQL together.
Also be careful when you use cache API & SQL together.
You can get unexpected behavior on this way for several cases. See [2]
1. https://apacheignite-sql.readme.io/docs/create-table
2. https://youtu.be/0lQy5J5hLJI?t=2051
On 07.05.2021 17:10, Henric wrote:
I tried to query data by partition index, when I insert data using cache API,
I can get data successfully, when I insert data using DML, I can't get data.
*I can get data by partition index using cache API*
IgniteCache cache = ignite.getOrCreateCache("cacheName");
cache.put(1, "v1");
ScanQuery sq = new ScanQuery(1); //1 is the id of partition used to store
entry created above
cache.query(sq).getAll();
*I can't get data using partition index which is insert by DML*
IgniteCache cache = ignite.getOrCreateCache("tableName");
cache.query(new SqlFieldsQuery("CREATE TABLE tableName (id LONG PRIMARY KEY,
name VARCHAR)")).getAll();
SqlFieldsQuery qry = new SqlFieldsQuery("INSERT INTO tableName (id, name)
value (?,?)");
cache.query(qry.setArgs(11L, "Mary Major")).getAll();
ScanQuery sq = new ScanQuery(11); //11 is the id of partition used to store
entry created above
cache.query(sq).getAll(); //nothing return here!
I tried SQL_PUBLIC_TABLENAME as cache name, I got Exception:
java.lang.ClassNotFoundException:
SQL_PUBLIC_TABLENAME_7b146bba_cd7f_452f_8abc
*Q: How can I query data inserted by DML using partition index? Thanks.*
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
--
Taras Ledkov
Mail-To: tled...@gridgain.com