文の先頭と末尾は、\Aと\zで表現する。
行の先頭と末尾は、^と$で表現する。
例
lines = "line1\nline2" # line1とline2を含め文字列全体でマッチする puts /\A.+1.+2\z/m === lines # line1だけでマッチする puts /^.+1$/ === lines
lines = "line1\nline2" # line1とline2を含め文字列全体でマッチする puts /\A.+1.+2\z/m === lines # line1だけでマッチする puts /^.+1$/ === lines
上位N番までの問合せの実行に、オフセットと、戻される行数または行数の割合を指定できます。
select * from table1 order by id offset 10 rows fetch first 5 rows only;
select * from table1 order by id offset 10 rows fetch first 5 rows with ties;
ALTER TABLE ACCOUNT ADD FOREIGN KEY (ADDRESS_CD) REFERENCES ADDRESS (CD) ON DELETE CASCADE;
TRUNCATE TABLE ADDRESS CASCADE;
func = -> 'use strict' arguments.callee
(function() { var func; func = function() { 'use strict'; return arguments.callee; }; }).call(this);
-- 常に生成した値を設定する(明示的に値を設定しようとするとエラーとなる) id number generated as identity not null -- generatedの後にalwaysを指定すると、常に生成した値を使用する -- デフォルト動作なので、上のオプション無しと同じ動きとなる id number generated always as identity not null -- by defaultを指定すると値の設定がない場合のみ、生成した値が設定されます。 -- on nullをby defaultの後に設定すると、挿入(更新)対象の値がnullの場合にも、生成した値が設定されます。 id number generated by default as identity not null
id number generated as identity( minvalue 100 maxvalue 999 cycle ) not null,
-- テーブル定義 create table test_table ( id number generated as identity( minvalue 100 maxvalue 999 cycle ) not null, name NVARCHAR2 (100) not null, primary key (id) ); -- INSERTの実行結果 SQL> insert into test_table (name) values ('なまえ'); 1 row created. SQL> select id from test_table; ID ---------- 100 SQL> insert into test_table (name) values ('なまえ'); 1 row created. SQL> select id from test_table; ID ---------- 100 101
SQL> insert into test_table (id, name) values (999, 'name'); insert into test_table (id, name) values (999, 'name') * ERROR at line 1: ORA-32795: cannot insert into a generated always identity column
create table on_null_test ( id number not null, char_col char(1) default on null '0', -- nullの場合は、「0」を代入する number_col number default on null 100, -- nullの場合は、「100」を代入する primary key (id) );
-- 主キー以外は指定しない INSERT INTO ON_NULL_TEST (id) values (1); -- nullを代入 INSERT INTO ON_NULL_TEST (id, char_col, number_col) values (2, null, null); -- null以外を代入 INSERT INTO ON_NULL_TEST (id, char_col, number_col) values (3, '1', 999);
ID CHAR_COL NUMBER_COL 1 0 100 2 0 100 3 1 999