Colonne Dinamiche in MariaDB 10

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.
MariaDB starting with 10.0

In MariaDB 10 le Colonne Dinamiche avranno i seguenti miglioramenti.

Supporto ai nomi

Ovunque si usassero i numeri per riferirsi alle colonne, sarà ora possibile utilizzare le stringhe:

  • Creare un record di una Colonna Dinamica:
COLUMN_CREATE("int", -1212 as int, "double", 1.23444e50 as double, "string", 'gdgd\\dhdjh"dhdhd' as char);
  • Alterare un record di una Colonna Dinamica (rimuovere la colonna chiamata "int" e aggiungerne una chiamata "intint"):
COLUMN_ADD(dynamiccolumns, "int", NULL, "intint", 12);
  • quando si cambia formato (da quello numerico a quello con i nomi):
COLUMN_ADD(COLUMN_CREATE(1,"string"), "1", NULL, "int", 12);
  • verificare se una colonna esiste
COLUMN_EXISTS(dynamic_column, "column1");
  • leggere il valore di una colonna:
COLUMN_GET(dynstr, "column1" as char(10));

Comportamenti modificati

  • L'output della lista delle colonne ora contiene le virgolette:
select column_list(column_create(1, 22, 2, 23));
+------------------------------------------+
| column_list(column_create(1, 22, 2, 23)) |
+------------------------------------------+
| `1`,`2`                                  |
+------------------------------------------+
select column_list(column_create('column1', 22, 'column2', 23)); 
+----------------------------------------------------------+
| column_list(column_create('column1', 22, 'column2', 23)) |
+----------------------------------------------------------+
| `column1`,`column2`                                      |
+----------------------------------------------------------+
  • L'interpretazione dei nomi delle colonne è stata modificata in modo che la stringa non sia più convertita in numero. Perciò alcuni trucchi "magici" non funzionano più: ad esempio "1test" e "1" ora sono trattati come nomi diversi:
select column_list(column_add(column_create('1a', 22), '1b', 23));
+------------------------------------------------------------+
| column_list(column_add(column_create('1a', 22), '1b', 23)) |
+------------------------------------------------------------+
| `1a`,`1b`                                                  |
+------------------------------------------------------------+
  • Vecchio comportamento:
select column_list(column_add(column_create('1a', 22), '1b', 23));
+------------------------------------------------------------+
| column_list(column_add(column_create('1a', 22), '1b', 23)) |
+------------------------------------------------------------+
| 1                                                          |
+------------------------------------------------------------+

Nuove funzioni

Le seguenti nuove funzioni sono state aggiunte alle Colonne Dinamiche in MariaDB 10

COLUMN_CHECK

This function is used to check a column's integrity. When it encounters an error it does not return illegal format errors but returns false instead. It also checks integrity more thoroughly and finds errors in the dynamic column internal structures which might not be found by other functions.

select column_check(column_create('column1', 22));
+--------------------------------------------+
| column_check(column_create('column1', 22)) |
+--------------------------------------------+
|                                          1 |
+--------------------------------------------+
select column_check('abracadabra');
+-----------------------------+
| column_check('abracadabra') |
+-----------------------------+
|                           0 |
+-----------------------------+

COLUMN_JSON

This function converts all dynamic column record content to a JSON array of objects which are pairs NAME:VALUE.

select column_json(column_create('column1', 1, 'column2', "two"));
+------------------------------------------------------------+
| column_json(column_create('column1', 1, 'column2', "two")) |
+------------------------------------------------------------+
| [{"column1":1},{"column2":"two"}]                          |
+------------------------------------------------------------+

Interface with Cassandra

Some internal changes were added to dynamic columns to allow them to serve as an interface to Apache Cassandra dynamic columns. The Cassandra engine may pack all columns which were not mentioned in the MariaDB interface table definition and even bring chages in the dynamic column contents back to the cassandra columns family (the table analog in cassandra).

See Also

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.