-
Praveenkumar Hulakund authored
The aim of the WL is to implement INVISIBLE COLUMNS feature. The user defined columns are always visible in the MySQL. But if user wants to hide some column(s) then the invisible columns feature is useful. A SQL statement uses invisible column by explicitly referring it. The WL provides following functionality: a) Creating invisible columns: A column visibility attribute is added to the column definition of CREATE TABLE and ALTER TABLE statements, column_definition: column_name data_type [NOT NULL | NULL ] [DEFAULT default_value] ............... [VISIBLE | INVISIBLE] ^^^^^^^^^^^^^^^^^^^^^^^ Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); ALTER TABLE t1 ADD COLUMN f3 INT INVISIBLE; Columns are visible by default. Table must have atleast one visible column. b) Accessing invisible columns: If <column list> of INSERT, REPLACE or LOAD statements is empty then while preparing a column list invisible columns are *not* included. DEFAULT or NULL values are inserted for invisible columns in this case. Invisible column should be explicitly referenced in the <column list> of INSERT, REPLACE and LOAD statement to insert a value. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); -- Value 1 is stored in column f2 and NULL in INVISIBLE column. INSERT INTO t1 VALUES (1); -- Value 3 is stored in INVISIBLE column and 4 in f2. INSERT INTO t1(f1, f2) VALUES (3, 4); b.1) Wild card expansion for SELECT statements: Invisible columns are not included in a column list while expanding wild card "*" in the SELECT query or natural join. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); INSERT INTO t1 VALUES (1); SELECT * FROM t1; +------+ | f2 | +------+ | 1 | +------+ Invisible columns are accessible when explicitly referenced in the query. Example: SELECT f1, f2 FROM t1; +------+------+ | f1 | f2 | +------+------+ | NULL | 1 | +------+------+ b) Altering column visibility attribute: Apart from supporting visibility attribute in the column definition for ALTER TABLE ... MODIFY COLUMN and ALTER TABLE ... CHANGE COLUMN, visibility clause is introduced in the ALTER TABLE ... ALTER [COLUMN] statement. alter_option: { ... ALTER [COLUMN] col_name {... | SET VISIBLE | SET INVISIBLE} } Example: ALTER TABLE t1 ALTER f1 SET VISIBLE; ALTER TABLE t1 ALTER f2 SET INVISIBLE; c) SHOW CREATE TABLE lists invisible columns. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); SHOW CREATE TABLE t1; Table: t1 Create Table: CREATE TABLE `t1` ( `f1` int DEFAULT NULL /*!80023 INVISIBLE */, `f2` int DEFAULT NULL ); Invisible columns are listed with versioned comment '/*!80023 INVISIBLE */'. d) SHOW COLUMN lists invisible columns. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); SHOW COLUMNS FROM t1 +-------+------+------+-----+---------+-----------+ | Field | Type | Null | Key | Default | Extra | +-------+------+------+-----+---------+-----------+ | f1 | int | YES | | NULL | INVISIBLE | | f2 | int | YES | | NULL | | +-------+------+------+-----+---------+-----------+ For invisible columns, EXTRA column contains value "INVISIBLE". e) INFORMATION_SCHEMA.COLUMNS table lists invisible column with value "INVISIBLE" in the EXTRA column. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); SELECT COLUMN_NAME, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +-------------+----------------------------+ | COLUMN_NAME | EXTRA | +-------------+----------------------------+ | f1 | INVISIBLE | | f2 | | +-------------+----------------------------+ f) INVISIBLE column is a non-standard SQL feature. WL follows ORACLE INVISIBLE column feature and makes feature suitable for MySQL. Change-Id: If296301b59a162a5c9344c2f3991c662a5147310
Praveenkumar Hulakund authoredThe aim of the WL is to implement INVISIBLE COLUMNS feature. The user defined columns are always visible in the MySQL. But if user wants to hide some column(s) then the invisible columns feature is useful. A SQL statement uses invisible column by explicitly referring it. The WL provides following functionality: a) Creating invisible columns: A column visibility attribute is added to the column definition of CREATE TABLE and ALTER TABLE statements, column_definition: column_name data_type [NOT NULL | NULL ] [DEFAULT default_value] ............... [VISIBLE | INVISIBLE] ^^^^^^^^^^^^^^^^^^^^^^^ Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); ALTER TABLE t1 ADD COLUMN f3 INT INVISIBLE; Columns are visible by default. Table must have atleast one visible column. b) Accessing invisible columns: If <column list> of INSERT, REPLACE or LOAD statements is empty then while preparing a column list invisible columns are *not* included. DEFAULT or NULL values are inserted for invisible columns in this case. Invisible column should be explicitly referenced in the <column list> of INSERT, REPLACE and LOAD statement to insert a value. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); -- Value 1 is stored in column f2 and NULL in INVISIBLE column. INSERT INTO t1 VALUES (1); -- Value 3 is stored in INVISIBLE column and 4 in f2. INSERT INTO t1(f1, f2) VALUES (3, 4); b.1) Wild card expansion for SELECT statements: Invisible columns are not included in a column list while expanding wild card "*" in the SELECT query or natural join. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); INSERT INTO t1 VALUES (1); SELECT * FROM t1; +------+ | f2 | +------+ | 1 | +------+ Invisible columns are accessible when explicitly referenced in the query. Example: SELECT f1, f2 FROM t1; +------+------+ | f1 | f2 | +------+------+ | NULL | 1 | +------+------+ b) Altering column visibility attribute: Apart from supporting visibility attribute in the column definition for ALTER TABLE ... MODIFY COLUMN and ALTER TABLE ... CHANGE COLUMN, visibility clause is introduced in the ALTER TABLE ... ALTER [COLUMN] statement. alter_option: { ... ALTER [COLUMN] col_name {... | SET VISIBLE | SET INVISIBLE} } Example: ALTER TABLE t1 ALTER f1 SET VISIBLE; ALTER TABLE t1 ALTER f2 SET INVISIBLE; c) SHOW CREATE TABLE lists invisible columns. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); SHOW CREATE TABLE t1; Table: t1 Create Table: CREATE TABLE `t1` ( `f1` int DEFAULT NULL /*!80023 INVISIBLE */, `f2` int DEFAULT NULL ); Invisible columns are listed with versioned comment '/*!80023 INVISIBLE */'. d) SHOW COLUMN lists invisible columns. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); SHOW COLUMNS FROM t1 +-------+------+------+-----+---------+-----------+ | Field | Type | Null | Key | Default | Extra | +-------+------+------+-----+---------+-----------+ | f1 | int | YES | | NULL | INVISIBLE | | f2 | int | YES | | NULL | | +-------+------+------+-----+---------+-----------+ For invisible columns, EXTRA column contains value "INVISIBLE". e) INFORMATION_SCHEMA.COLUMNS table lists invisible column with value "INVISIBLE" in the EXTRA column. Example: CREATE TABLE t1 (f1 INT INVISIBLE, f2 INT); SELECT COLUMN_NAME, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +-------------+----------------------------+ | COLUMN_NAME | EXTRA | +-------------+----------------------------+ | f1 | INVISIBLE | | f2 | | +-------------+----------------------------+ f) INVISIBLE column is a non-standard SQL feature. WL follows ORACLE INVISIBLE column feature and makes feature suitable for MySQL. Change-Id: If296301b59a162a5c9344c2f3991c662a5147310
Loading