MariaDB模式创建

MariaDB模式创建,mariadb,Mariadb,我试图在MariaDB中定义一组对象,即 use SocialCartography; drop table if exists Relationship; drop table if exists Person; create table if not exists Person ( Id int unsigned not null auto_increment primary key, Name varchar(255) null, DoB date null,

我试图在MariaDB中定义一组对象,即

use SocialCartography;

drop table if exists Relationship;
drop table if exists Person;

create table if not exists Person (
    Id int unsigned not null auto_increment primary key,
    Name varchar(255) null, 
    DoB date null,
    DoD date null,
    PictureURL varchar(8192) null
);

create table if not exists Relationship (
    Id int unsigned not null auto_increment primary key,
    Since date null,
    Until date null,
    Type varchar(255),
    First int unsigned not null,
    Second int unsigned not null,
    PictureURL varchar(8192) null,

    constraint `fk_first_friend` 
    foreign key (first) references Person (Id)
        on delete cascade
        on update restrict,

    constraint `fk_second_friend` 
    foreign key (second) references Person (Id)
        on delete cascade
        on update restrict
);
go

delimiter //
create or replace procedure upsert_person (
    in pId int unsigned,
    in pName varchar(255),
    in pDoB date,
    in pDoD date,
    in pPictureURL varchar(8192)
)
as
begin
    if exists(select Id from Person where Id = pId) 
    then
        update Person
        set
            Name = pName,
            DoB = pDoB, 
            DoD = pDoD,
            PictureURL = pPictureURL
        where
            Id = pId;

        select pId as Id;
    else
        insert into Person
        (
            Name,
            DoB,
            DoD,
            PictureURL
        )
        values
        (p
            pName,
            pDoB,
            pDoD,
            pPictureURL
        );

        select last_insert_id() as Id;
    end if;
end //
delimiter ;

delimiter //
create or replace procedure delete_person (
    in pId int unsigned
)
begin
    delete Person
    where Id = pId;
end //
delimiter ;

delimiter //
create or replace procedure upsert_relationship ( 
    in pId int unsigned,
    in pSince date,
    in pUntil date,
    in pType nvarchar(255),
    in pFirst int unsigned,
    in pSecond int unsigned,
    in pPictureURL nvarchar(8192)
)
begin
    if exists(select Id from Relationship where Id = pId) 
    then
        update Relationship 
        set
           Since = pSince,
           Until = pUntil,
           Type = pType,
           First = pFirst,
           Second = pSecond,
           PictureURL = pPictureURL
        where
            Id = pId;

        select pId as Id;
    else
        insert into Relationship
        (
           Since,
           Until,
           Type,
           First,
           Second,
           PictureURL
        )
        values
        (
           pSince,
           pUntil,
           pType,
           pFirst,
           pSecond,
           pPictureURL
        );

        select last_insert_id() as Id;
    end if;
end //
delimiter ;

delimiter //
create or replace procedure delete_relationship (
    in pId int unsigned
)
begin
    delete Relationship
    where Id = pId;
end //
delimiter ;
但我一直犯的错误是

ERROR 1064 (42000) at line 36: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'procedure upsert_person (
in pId int unsigned,
in pName varchar(255),
' at line 1
知道我做错了什么吗?我已经试过nvarchar,但还是回到了varchar,因为我找不到关于如何使用nvarchar的文档


错误消息似乎没有太大帮助,因为我试图在所示语法附近找到错误,但无法找到

摆脱
go
;这属于其他产品

或REPLACE
在10.1.3之前不可用;你正在运行哪个版本