Search code examples
sqldml

Can't update table value with schema name


CREATE TABLE DBD_D_155150401111052.STUDENT(
    STUDENT_ID VARCHAR(20) NOT NULL,
    PRIMARY KEY (STUDENT_ID),
    STATE_ID CHAR(3),
    CONSTRAINT STATE_ID FOREIGN KEY (STATE_ID) REFERENCES DBD_D_155150401111052.PROPINSI (STATE_ID),
    CITY_ID CHAR(3),
    CONSTRAINT CITY_ID FOREIGN KEY (CITY_ID) REFERENCES DBD_D_155150401111052.KOTA (CITY_ID),
    NAME VARCHAR(45),
    BIRTH_DATE DATE,
    COURSE VARCHAR(10)
    );

INSERT INTO DBD_D_155150401111052.STUDENT (STUDENT_ID, NAME, BIRTH_DATE, CITY_ID, STATE_ID, COURSE)
VALUES  ('1111171', 'DEMILOV', '1997-05-01', 'A01', '001', 'SI-A'),
        ('1111172', 'MICHAEL', '1996-03-20', 'A01', '001', 'SI-A'),
        ('1111181', 'IRVING', '1998-10-14', 'C01', '003', 'IF-B'),
        ('1111182', 'JHON', '1998-08-15', 'B01', '002', 'IF-C'),
        ('1111191', 'THEODORE', '1996-01-02', 'A03', '001', 'IF-A'),
        ('1111192', 'SALLY', '1995-12-31', 'A02', '001', 'SI-B'),
        ('1111212', 'JASON', '1997-07-28', 'A02', '001', 'IF-B'),
        ('1111213', 'DAVID', '1998-11-11', 'B02', '002', 'IF-C'),
        ('1111214', 'JAMES', '1997-12-12', 'C01', '003', 'SI-B'),
        ('1111215', 'HELENA', '1996-06-08', 'C01', '003', 'IF-B');


UPDATE TABLE DBD_D_155150401111052.STUDENT
SET COURSE = 'SI-B'
WHERE STUDENT_ID = '1111171';

I can't execute the last query. The warning says "JOIN" was expected instead of ".", but I have no idea how to fix it. The table value can't updated because table name include schema, is there any way to update the value?


Solution

  • TABLE is not part of UPDATE syntax. I would suggest you try:

    UPDATE DBD_D_155150401111052.STUDENT
        SET COURSE = 'SI-B'
        WHERE STUDENT_ID = '1111171';