MariaDB [cms]> select userLabel from cnf_network_function where nfType='du' order by id desc limit 1\G
*************************** 1. row ***************************
userLabel: mvnr-cv11|me-mtcil1|123005011
===
userLabel: mvnr-cv11|me-mtcil1|123005011
I need only number from above column is it possible?
like
select userLabel from cnf_network_function ........;
output should be
select userLabel from cnf_network_function ........;
*************************** 1. row ***************************
userLabel:123005011
expectation was --
select userLabel from cnf_network_function ........;
*************************** 1. row ***************************
userLabel:123005011
Related
How to create a trigger which interdicts insertion of symbols and space in a certain column and after insertion just to have only the upper letters
for example:
insert into tale xxx values '"&$))(/-$:&##¥*|^]asjdj';
and the result should be the following:
ASJDJ
thank you
a lot of functions procedures trigger and nothing was right
Add a new column to the table and update that column extracting only the letters from the column with special characters.
Using your eg.
Add new column value in tale table. Right after inserting the xxx column do the updates like:
update tale set value = upper(regexp_substr(xxx,'[[:alpha:]]+'));
That would be a row-level trigger which fires both before insert or update on table so that value is modified in any case. There are various options which let you remove everything but letters; regular expression is simple enough.
Sample table:
SQL> create table test (col varchar2(40));
Table created.
Trigger:
SQL> create or replace trigger trg_biu_test
2 before insert or update on test
3 for each row
4 begin
5 :new.col := upper(regexp_replace(:new.col, '[^[:alpha:]]'));
6 end;
7 /
Trigger created.
Testing:
SQL> insert into test (col) values ('"&$))(/-$:&##¥*|^]asjdj');
1 row created.
SQL> select * from test;
COL
----------------------------------------
YASJDJ
SQL> update test set col = '25xyz';
1 row updated.
SQL> select * from test;
COL
----------------------------------------
XYZ
SQL>
I implemented data in rest encryption on MariaDB 10.5 using the plugin file_key_management.so.
Here is my current configuration:
plugin_dir=/usr/lib/mysql/plugin
plugin_load_add = file_key_management.so
loose_file_key_management_filename = /etc/mysql/keyfile.enc
loose_file_key_management_filekey = FILE:/etc/mysql/keyfile.key
loose_file_key_management_encryption_algorithm = AES_CTR
encrypt_binlog = ON
encrypt_tmp_disk_tables = ON
encrypt_tmp_files = ON
innodb_encrypt_tables = FORCE
innodb_encrypt_log = ON
innodb_encryption_threads = 4
innodb_encrypt_temporary_tables = ON
innodb_encryption_rotate_key_age = 1
innodb_encryption_rotation_iops = 3000
I was able to rotate the encryption key for all tables except for innodb_system
MariaDB [(none)]> SELECT NAME,CURRENT_KEY_ID FROM information_schema.INNODB_TABLESPACES_ENCRYPTION where ENCRYPTION_SCHEME='1' and NAME like "%innodb%" \G
*************************** 1. row ***************************
NAME: innodb_system
CURRENT_KEY_ID: 1
*************************** 2. row ***************************
NAME: mysql/innodb_table_stats
CURRENT_KEY_ID: 3
*************************** 3. row ***************************
NAME: mysql/innodb_index_stats
CURRENT_KEY_ID: 3
Using the same query I was not able to rotate the key
MariaDB [(none)]> alter table innodb_system encryption_key_id=3;
ERROR 1046 (3D000): No database selected
I found some documentation on how to rotate on Mysql and if I understood correctly this is like a master key for innodb.
mysql> ALTER INSTANCE ROTATE INNODB MASTER KEY;
Which it does not work.
How can I rotate the key ?
ERROR 1046 (3D000): No database selected
Before doing anything to a TABLE (such as ALTER), you must specify which database it is in (eg, such as with a USE).
(There may be further mistakes.)
I recently moved to mariadb 10.5, and have encountered this specific output where a percentage is shown along with rows in explain output. I couldn't find any documentation for the same, probably it's a new feature.
What exactly does that mean? Is it the probability of some kind regarding rows being read?
MariaDB [c6b2c772b91fd3d8]> explain
select
`execute_action`, `state_type`
from
`tabSuperflow Document State`
where
`parent` = 'Check Point'
and `state` = 'Pending TSM Approval - Delivery'
order by
modified desc \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: tabSuperflow Document State
type: ref|filter
possible_keys: parent,index_on_state
key: index_on_state|parent
key_len: 563|563
ref: const
rows: 1 (17%)
Extra: Using index condition; Using where; Using filesort; Using rowid filter
1 row in set (0.001 sec)
Found out the answer in a rather unrelated documentation
https://mariadb.com/kb/en/rowid-filtering-optimization/
rows column shows the expected filter selectivity, it is 5%.
So basically that percentage shows expected filter selectivity, i.e. rows which will be filtered using where clause in this step. This output can also be seen in explain extended output in the filtered column.
MariaDB [c6b2c772b91fd3d8]> explain extended select `execute_action`, `state_type` from `tabSuperflow Document State` where `parent` = 'Check Point' and `state` = 'Pending TSM Approval - Delivery' order by modified desc \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: tabSuperflow Document State
type: ref|filter
possible_keys: parent,index_on_state
key: index_on_state|parent
key_len: 563|563
ref: const
rows: 1 (17%)
filtered: 16.67
Extra: Using index condition; Using where; Using filesort; Using rowid filter
1 row in set, 1 warning (0.001 sec)
I would like to create table that have limited numbers of rows.
For example if we try insert data into that table where rownumber is bigger than 2.000, that return some error or something.
How to manage this?
An approach could be by creating a trigger to check the number of inserted rows; for example, say you have this table
create table notManyRows(n number)
and you want to limit the number of rows to 3, you can add a trigger like:
create or replace trigger notManyRowsTrg
after insert on notManyRows
declare
vCheck number;
begin
select count(*)
into vCheck
from notManyRows;
--
if vCheck > 3 then
raise_application_error(-20001, 'Too many rows in the table');
end if;
end;
How it works:
SQL> insert into notManyRows values (1);
1 row created.
SQL> insert into notManyRows values (1);
1 row created.
SQL> insert into notManyRows values (1);
1 row created.
SQL> insert into notManyRows values (1);
insert into notManyRows values (1)
*
ERROR at line 1:
ORA-20001: Too many rows in the table
ORA-06512: at "ALEK.NOTMANYROWSTRG", line 9
ORA-04088: error during execution of trigger 'ALEK.NOTMANYROWSTRG'
SQL>
I have a table in my database... I want to insert a row to table1 by reading from a record on sqlite_sequence... I know the sqlite_sequence table is for AUTOINCREMENT... and also my table1 has AUTOINCREMENT for _id as well...
I tried this:
INSERT INTO table1 (column_1, column_2) VALUES ((SELECT seq FROM sqlite_sequence WHERE name=other_table),`other_column`);
but after inserting, inserted row will be deleted in table1...
I want to know the last row id in other_table... and i tried with last_insert_rowid() instead of (SELECT seq FROM sqlite_sequence WHERE name=other_table)... but the result was same...
Where is my mistake?? thanks!