Appendix 14List Of Available Sql Commands For Cpu Module Database Access Function - Mitsubishi Electric MELSEC iQ-R-R00CPU User Manual

Melsec iq-r series cpu module application user's manual
Table of Contents

Advertisement

Appendix 14
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.
Syntax
CREATE TABLE [table name] ([field name] [data type] [option], [field name] [data type] [option], , [field name] [data type] [option]);
■Option
Item
Description
Primary key
Maintains the uniqueness of a value stored in the field. (NULL is not
constraint
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.
Foreign key
Refers to the value of a field of another table. Only the field with the
constraint
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.
NOT NULL
Disables storing NULL values. (Always store a value other than NULL.)
constraint
■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
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.
Syntax
DROP TABLE [ table name];
■Application example
• To delete table 1
DROP TABLE "table1";
APPX
996
Appendix 14 List of Available SQL Commands for CPU Module Database Access Function
List of Available SQL Commands for CPU
Module Database Access Function
Syntax
PRIMARY KEY [key name]
FOREIGN KEY [key name] REFERENCES [reference table
name] ([reference field name])
NOT NULL
*1
since it needs to be defined with the data

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents