I installed IBM - DB2 Express Server Edition and I'm trying to run an EXPLAIN statement on a query.
I already called the following procedure to create the EXPLAIN tables on SYSTOOLS
CALL SYSPROC.SYSINSTALLOBJECTS('EXPLAIN', 'C',
null), null))
and created the PLAN_TABLE for my user
CREATE TABLE PLAN_TABLE
(QUERYNO INTEGER NOT NULL,
QBLOCKNO SMALLINT NOT NULL,
APPLNAME CHAR(8) NOT NULL,
PROGNAME VARCHAR(128) NOT NULL,
PLANNO SMALLINT NOT NULL,
METHOD SMALLINT NOT NULL,
CREATOR VARCHAR(128) NOT NULL,
TNAME VARCHAR(128) NOT NULL,
TABNO SMALLINT NOT NULL,
ACCESSTYPE CHAR(2) NOT NULL,
MATCHCOLS SMALLINT NOT NULL,
ACCESSCREATOR VARCHAR(128) NOT NULL,
ACCESSNAME VARCHAR(128) NOT NULL,
INDEXONLY CHAR(1) NOT NULL,
SORTN_UNIQ CHAR(1) NOT NULL,
SORTN_JOIN CHAR(1) NOT NULL,
SORTN_ORDERBY CHAR(1) NOT NULL,
SORTN_GROUPBY CHAR(1) NOT NULL,
SORTC_UNIQ CHAR(1) NOT NULL,
SORTC_JOIN CHAR(1) NOT NULL,
SORTC_ORDERBY CHAR(1) NOT NULL,
SORTC_GROUPBY CHAR(1) NOT NULL,
TSLOCKMODE CHAR(3) NOT NULL,
TIMESTAMP CHAR(16) NOT NULL,
REMARKS VARCHAR(762) NOT NULL,
PREFETCH CHAR(1) NOT NULL WITH DEFAULT,
COLUMN_FN_EVAL CHAR(1) NOT NULL WITH DEFAULT,
MIXOPSEQ SMALLINT NOT NULL WITH DEFAULT,
VERSION VARCHAR(64) NOT NULL WITH DEFAULT,
COLLID VARCHAR(128) NOT NULL WITH DEFAULT,
ACCESS_DEGREE SMALLINT ,
ACCESS_PGROUP_ID SMALLINT ,
JOIN_DEGREE SMALLINT ,
JOIN_PGROUP_ID SMALLINT ,
SORTC_PGROUP_ID SMALLINT ,
SORTN_PGROUP_ID SMALLINT ,
PARALLELISM_MODE CHAR(1) ,
MERGE_JOIN_COLS SMALLINT ,
CORRELATION_NAME VARCHAR(128) ,
PAGE_RANGE CHAR(1) NOT NULL WITH DEFAULT,
JOIN_TYPE CHAR(1) NOT NULL WITH DEFAULT,
GROUP_MEMBER CHAR(8) NOT NULL WITH DEFAULT,
IBM_SERVICE_DATA VARCHAR(254) FOR BIT DATA NOT NULL WITH DEFAULT,
WHEN_OPTIMIZE CHAR(1) NOT NULL WITH DEFAULT,
QBLOCK_TYPE CHAR(6) NOT NULL WITH DEFAULT,
BIND_TIME TIMESTAMP NOT NULL WITH DEFAULT,
OPTHINT VARCHAR(128) NOT NULL WITH DEFAULT,
HINT_USED VARCHAR(128) NOT NULL WITH DEFAULT,
PRIMARY_ACCESSTYPE CHAR(1) NOT NULL WITH DEFAULT,
PARENT_QBLOCKNO SMALLINT NOT NULL WITH DEFAULT,
TABLE_TYPE CHAR(1) ,
TABLE_ENCODE CHAR(1) NOT NULL WITH DEFAULT,
TABLE_SCCSID SMALLINT NOT NULL WITH DEFAULT,
TABLE_MCCSID SMALLINT NOT NULL WITH DEFAULT,
TABLE_DCCSID SMALLINT NOT NULL WITH DEFAULT,
ROUTINE_ID INTEGER NOT NULL WITH DEFAULT,
CTEREF SMALLINT NOT NULL WITH DEFAULT,
STMTTOKEN VARCHAR(240))
Then I run the EXPLAIN statement as below (I have also tried EXPLAIN PLAN instead of EXPLAIN ALL)
EXPLAIN ALL SET QUERYNO=1 FOR SELECT * FROM SYSIBM.SYSDUMMY1
I can see the EXPLAIN tables such as EXPLAIN_INSTANCE or EXPLAIN_STATEMENT do get data in them, but the PLAN_TABLE is empty.
Is there something I'm missing here or still need to configure?
I'm used to doing EXPLAINs in a mainframe environment and my PLAN_TABLE always gets filled up correctly.
Thanks!
Related
I have database with .sql, I want to import that .sql file into SQL Server 2012 using Management Studio.
When I tried to import the data, I'm getting an error:
Msg 156, Level 15, State 1, Line 76
Incorrect syntax near the keyword 'NOT'.
[![enter image description here][1]][1]
CREATE TABLE ct_bookings(
id int NOT NULL,
order_id bigint NOT NULL,
client_id bigint NOT NULL,
order_date date NOT NULL,
booking_date_time datetime NOT NULL,
service_id int NOT NULL,
method_id int NOT NULL,
method_unit_id int NOT NULL,
method_unit_qty int NOT NULL,
method_unit_qty_rate double NOT NULL,
booking_status varchar(10) not null ('A','C','R','CC','CS','CO','MN','RS') NOT NULL COMMENT 'A=active, C=confirm, R=Reject, CC=Cancel by Client, CS=Cancel by service provider,CO=Completed,MN=MARK AS NOSHOW',
`reject_reason` varchar(200) NOT NULL,
`reminder_status` enum('0','1') NOT NULL DEFAULT '0' COMMENT '0=Email Not Sent,1=Email Sent',
`lastmodify` datetime NOT NULL,
`read_status` enum('R','U') NOT NULL DEFAULT 'U'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
How can I solve this issue?
Please help me out. Thanks in advance.
in MySQL:-
CREATE TABLE ct_addon_service_rate(
id int(11) NOT NULL,
addon_service_id int(11) NOT NULL,
unit varchar(20) NOT NULL,
rules VARCHAR(10) NOT NULL CHECK (rules IN('E', 'G')),
rate DOUBLE NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Equals in SQL Server:-
Create TABLE ct_addon_service_rate (
id int NOT NULL,
addon_service_id int NOT NULL,
unit varchar(20) NOT NULL,
rules char(1) not null,
rate FLOAT(25) NOT NULL,
CHECK (rules in ('E', 'G'))
)
Update:-
In MySQL:-
CREATE TABLE ct_bookings(
id int NOT NULL,
order_id bigint NOT NULL,
client_id bigint NOT NULL,
order_date date NOT NULL,
booking_date_time datetime NOT NULL,
service_id int NOT NULL,
method_id int NOT NULL,
method_unit_id int NOT NULL,
method_unit_qty int NOT NULL,
method_unit_qty_rate double NOT NULL,
booking_status varchar(10) not null ('A','C','R','CC','CS','CO','MN','RS') NOT NULL COMMENT 'A=active, C=confirm, R=Reject, CC=Cancel by Client, CS=Cancel by service provider,CO=Completed,MN=MARK AS NOSHOW',
`reject_reason` varchar(200) NOT NULL,
`reminder_status` enum('0','1') NOT NULL DEFAULT '0' COMMENT '0=Email Not Sent,1=Email Sent',
`lastmodify` datetime NOT NULL,
`read_status` enum('R','U') NOT NULL DEFAULT 'U'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Equals in SQL Server:-
CREATE TABLE ct_bookings(
id int NOT NULL,
order_id bigint NOT NULL,
client_id bigint NOT NULL,
order_date date NOT NULL,
booking_date_time datetime NOT NULL,
service_id int NOT NULL,
method_id int NOT NULL,
method_unit_id int NOT NULL,
method_unit_qty int NOT NULL,
method_unit_qty_rate float(25) NOT NULL,
booking_status varchar(10) not null check (booking_status in ('A','C','R','CC','CS','CO','MN','RS')),
/*COMMENT 'A=active, C=confirm, R=Reject, CC=Cancel by Client, CS=Cancel by service provider,CO=Completed,MN=MARK AS NOSHOW', */
reject_reason varchar(200) NOT NULL,
reminder_status char(1)NOT NULL check (reminder_status in ('0','1')) DEFAULT '0', /*COMMENT '0=Email Not Sent,1=Email Sent', */
lastmodify datetime NOT NULL,
read_status char(1) NOT NULL check (read_status in ('R','U')) DEFAULT 'U'
)
Update 2:-
in MySQL:-
CREATE TABLE ct_email_templates (
id int NOT NULL,
email_subject varchar(200) COLLATE Latin1_General_CI_AS NOT NULL,
email_message text COLLATE Latin1_General_CI_AS NOT NULL,
default_message text COLLATE Latin1_General_CI_AS NOT NULL,
email_template_status varchar(10) NOT NULL check(email_template_status in('E','D')) COLLATE Latin1_General_CI_AS,
email_template_type varchar(10) check(email_template_type IN('A','C','R','CC','RS','RM')) COLLATE Latin1_General_CI_AS NOT NULL COMMENT 'A=active, C=confirm, R=Reject, CC=Cancel by Client, RS=Reschedule, RM=Reminder',
user_type` enum('A','C') COLLATE utf8_unicode_ci NOT NULL COMMENT 'A=Admin,C=client'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Equals in SQL Server:-
CREATE TABLE ct_email_templates (
id int NOT NULL,
email_subject varchar(200) COLLATE Latin1_General_CI_AS NOT NULL,
email_message text COLLATE Latin1_General_CI_AS NOT NULL,
default_message text COLLATE Latin1_General_CI_AS NOT NULL,
email_template_status varchar(10) COLLATE Latin1_General_CI_AS NOT NULL check(email_template_status in('E','D')) ,
email_template_type varchar(10) COLLATE Latin1_General_CI_AS check(email_template_type IN('A','C','R','CC','RS','RM')) NOT NULL, /*COMMENT 'A=active, C=confirm, R=Reject, CC=Cancel by Client, RS=Reschedule, RM=Reminder',
user_type` enum('A','C') COLLATE utf8_unicode_ci NOT NULL COMMENT 'A=Admin,C=client' */
)
create table dvds(
dvdid number not null primary key,
dvdname varchar(60) not null,
numdisks number not null default 1,
yearrlsd date not null,
mtypeid varchar(4) not null,
stuid varchar(4) not null,
ratingid varchar(4) not null,
formid char(2) not null,
statid char(3) not null,
foreign key (mtypeid) references movietypes (mtypeid)
)
whrn i am running this command in oracle it is giving error:
missing right parenthesis
but after removing default it is working
The default value should come before the constraints (not null);
numdisks number default 1 not null,
SQLfiddle.
could someone have a look at this for me, I can't seem to find why it is not working.
CREATE TABLE Person(
Person_ID int auto_increment NOT NULL,
Person_Type_ID int NOT NULL,
Create_Date datetime NOT NULL ,
Modify_Date datetime NOT NULL ,
First_Name varchar(50) NOT NULL,
Surname varchar(50) NOT NULL,
DOB date NOT NULL,
Gender char(1) NOT NULL CHECK (Gender ='f' OR Gender ='m'),
Archive char(1) NULL,
Allergies varchar(200) NOT NULL,
Dietry_Requirements varchar(200) NOT NULL,
Disabilities varchar(200) NOT NULL,
Medicine_Requirements varchar(200) NOT NULL,
username varchar (30) NOT NULL,
password varchar (30) NOT NULL,
CONSTRAINT PK_Person_ID PRIMARY KEY (Person_ID)
CONSTRAINT FK_Person_Type_ID FOREIGN KEY (Person_Type_ID)
REFERENCES Person_Type (Person_Type_ID));
You missed a comma! This should work...
CREATE TABLE Person(
Person_ID int auto_increment NOT NULL,
Person_Type_ID int NOT NULL,
Create_Date datetime NOT NULL ,
Modify_Date datetime NOT NULL ,
First_Name varchar(50) NOT NULL,
Surname varchar(50) NOT NULL,
DOB date NOT NULL,
Gender char(1) NOT NULL CHECK (Gender ='f' OR Gender ='m'),
Archive char(1) NULL,
Allergies varchar(200) NOT NULL,
Dietry_Requirements varchar(200) NOT NULL,
Disabilities varchar(200) NOT NULL,
Medicine_Requirements varchar(200) NOT NULL,
username varchar (30) NOT NULL,
password varchar (30) NOT NULL,
CONSTRAINT PK_Person_ID PRIMARY KEY (Person_ID),
CONSTRAINT FK_Person_Type_ID FOREIGN KEY (Person_Type_ID)
REFERENCES Person_Type (Person_Type_ID));
this is my trigger
ALTER trigger [dbo].[addpay]
on [dbo].[pays]
after insert
as
declare #idtutor int
set #idtutor =(select idtutor from inserted)
begin
insert into pays (idtutor,nopay,datex,paythismonth)values (#idtutor,600,GETDATE(),'no')
end
but it doesn't add a new pays after inserted a tutor... i dont watch any bug, mistake, why doesn't it work
my tables
create table Tutor
(
[IdTutor] int primary key identity not null,
[Nombre] varchar(150) not null,
[ApellidoPaterno] varchar (150) not null,
[ApellidoMaterno] varchar (150) not null,
[EstadoCivil] varchar (10) not null,
[FechaNacimiento] varchar(50),
[Municipio] varchar(150) not null,
[Estado] varchar(150) not null,
[Direccion] varchar(250) not null,
[Sexo] varchar (9) not null,
[TelefonoTutor] char(10) not null,
[CelularTutor] char(15) not null,
[EmailTutor] char(50) not null,
[Empresa] varchar(150) not null,
[Ocupacion] varchar(250) not null,
[DireccionEmpresa] varchar (250) not null,
[TelefonoEmpresa] char(10) not null,
[CelularEmpresa] char(15) not null,
[EmailEmpresa] varchar(50) not null
)
create table pays
(
idpay int primary key not null identity,
idtutor int not null,
nopay float,
datex datetime,
paythismonth varchar(2)
)
You need to create the trigger on the table for where you want it to fire when a new record is inserted (Tutor in this case).
Additionally you need to remember that inserts/update statements can affect multiple rows so assigning to scalar variables won't work. The trigger you need is
CREATE TRIGGER YourTrigger
ON [dbo].[Tutor]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO pays
(idtutor,
nopay,
datex,
paythismonth)
SELECT idtutor,
600,
GETDATE(),
'no'
FROM inserted
END
You will also need to drop the other trigger in your question with DROP TRIGGER [dbo].[addpay]
I'm doing some custom database work for a module for Drupal and I get the following SQL error when trying to create my table:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL, rooms INT DEFAULT NULL, adults INT DEFAULT NULL, children' at line 14 query: CREATE TABLE dr_enquiry ( eId INT unsigned NOT NULL auto_increment, eKey VARCHAR(16) NOT NULL, dateSent INT NOT NULL DEFAULT 0, status VARCHAR(30) NOT NULL DEFAULT 'Unanswered', custName VARCHAR(50) NOT NULL, custEmail VARCHAR(200) NOT NULL, custPhone VARCHAR(25) NOT NULL, custCountry VARCHAR(40) NOT NULL, custIP VARCHAR(11) DEFAULT NULL, offerName VARCHAR(100) NOT NULL, offerURL VARCHAR(200) NOT NULL, arrival DATETIME DEFAULT NULL, departure DEFAULT NULL, rooms INT DEFAULT NULL, adults INT DEFAULT NULL, children INT DEFAULT NULL, childAges VARCHAR(32) DEFAULT NULL, toddlers INT DEFAULT NULL, toddlerAges VARCHAR(32) DEFAULT NULL, catering VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, agent VARCHAR(100) DEFAULT NULL, voucher VARCHAR(100) DEFAULT NULL, PRIMARY KEY (eId) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/travelco/public_html/includes/database.inc on line 550.
The 'departure' field doesn't seem to have a type eg varchar, mediumint etc. Try adding one and see if that solves your problem :)
Nullability is not set using a DEFAULT constraint. Thus, the compiler is balking at each instance of DEFAULT NULL. Thus, the create statement should look like:
CREATE TABLE dr_enquiry (
eId INT unsigned NOT NULL auto_increment
, eKey VARCHAR(16) NOT NULL
, dateSent INT NOT NULL DEFAULT 0
, status VARCHAR(30) NOT NULL DEFAULT 'Unanswered'
, custName VARCHAR(50) NOT NULL
, custEmail VARCHAR(200) NOT NULL
, custPhone VARCHAR(25) NOT NULL
, custCountry VARCHAR(40) NOT NULL
, custIP VARCHAR(11) NULL
, offerName VARCHAR(100) NOT NULL
, offerURL VARCHAR(200) NOT NULL
, arrival DATETIME NULL
, departure DATETIME NULL
, rooms INT NULL
, adults INT NULL
, children INT NULL
, childAges VARCHAR(32) NULL
, toddlers INT NULL
, toddlerAges VARCHAR(32) NULL
, catering VARCHAR(255) NULL
, comments VARCHAR(255) NULL
, agent VARCHAR(100) NULL
, voucher VARCHAR(100) NULL
, PRIMARY KEY (eId)
)
(Oh and departure did not have a datatype as richsage mentioned. I presumed it was DateTime.)