![Mitsubishi Electric MELSEC iQ-R-R00CPU User Manual Download Page 998](http://html.mh-extra.com/html/mitsubishi-electric/melsec-iq-r-r00cpu/melsec-iq-r-r00cpu_user-manual_239139998.webp)
996
APPX
Appendix 14 List of Available SQL Commands for CPU Module Database Access Function
Appendix 14
List of Available SQL Commands for CPU
Module Database Access Function
This section describes the available SQL commands for the CPU module database access function.
Data Definition
CREATE TABLE
This command creates a table in the database.
■
Option
■
Application example
• To create table1 (fld1 (integer type, primary key (key name: pk1)), fld2 (integer type), fld3 (character string type (120
characters, NOT NULL)))
CREATE TABLE "table1" ("fld1" INT PRIMARY KEY "pk1", "fld2" INT, "fld3" NLSCHAR (120) NOT NULL);
• To create table2 (fld1 (integer type, foreign key (key name: fk1, reference: table1 fld1)), fld2 (BOOLEAN type), fld3 (single-
precision real number type))
CREATE TABLE "table2" ("fld1" INT FOREIGN KEY "fk1" REFERENCES "table1" ("fld1"), "fld2" BOOLEAN, "fld3" REAL);
■
Precautions
• To define the NLSCHAR field, check the data size of the field.
• Define the NLSCHAR type with the size specified in NLSCHAR = (n+1)
3
*1
since it needs to be defined with the data
size. For example, the definition is 39 characters for "fld3" NLSCHAR (120) of table1 in the application example.
*1 n indicates the number of characters.
DROP TABLE
This command deletes the specified table in the database.
■
Application example
• To delete table 1
DROP TABLE "table1";
Syntax
CREATE TABLE [table name] ([field name] [data type] [option], [field name] [data type] [option],
, [field name] [data type] [option]);
Item
Description
Syntax
Primary key
constraint
Maintains the uniqueness of a value stored in the field. (NULL is not
available.) Only one primary key constraint can be set per table.
Key names must be up to 16 single-byte alphabetical characters and
are case sensitive.
PRIMARY KEY [key name]
Foreign key
constraint
Refers to the value of a field of another table. Only the field with the
name where the primary key constraint of another table is set can be
set as the reference field. (Always set the same field name to the
reference field and own field.)
Key names must be up to 16 single-byte alphabetical characters and
are case sensitive.
FOREIGN KEY [key name] REFERENCES [reference table
name] ([reference field name])
NOT NULL
constraint
Disables storing NULL values. (Always store a value other than NULL.)
NOT NULL
Syntax
DROP TABLE [ table name];
Summary of Contents for MELSEC iQ-R-R00CPU
Page 2: ......
Page 151: ...9 MONITOR FUNCTION 9 1 Real Time Monitor Function 149 9 MEMO ...
Page 323: ...18 SEQUENCE SCAN SYNCHRONIZATION SAMPLING FUNCTION 321 18 MEMO ...
Page 330: ...328 20 ROUTING SETTING 20 3 Precautions MEMO ...
Page 423: ...26 BASIC CONCEPT 26 8 State Transition of the Redundant System 421 26 MEMO ...
Page 1014: ...1012 APPX Appendix 15 Added and Enhanced Functions MEMO ...
Page 1027: ......