Error mengimport file sql pada CMD

Masalah:

ERROR 1064 (42000) at line 7: 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 'delete foreign key FK_ANGGOTA_MEMILIKI_PROGRAM_

end if' at line 3

Isi file sql:

/*==============================================================*/

/\* DBMS name:      Sybase SQL Anywhere 12                       */

/\* Created on:     5/27/2022 9:34:03 PM                         */

/*==============================================================*/

if exists(select 1 from sys.sysforeignkey where role='FK_ANGGOTA_MEMILIKI_PROGRAM_') then

    alter table anggota

       delete foreign key FK_ANGGOTA_MEMILIKI_PROGRAM_

end if;

if exists(select 1 from sys.sysforeignkey where role='FK_BUKU_JENIS_BUK_JENIS_BU') then

    alter table buku

       delete foreign key FK_BUKU_JENIS_BUK_JENIS_BU

end if;

if exists(select 1 from sys.sysforeignkey where role='FK_TRANSAKS_ANGGOTA_P_ANGGOTA') then

    alter table transaksi_peminjaman

       delete foreign key FK_TRANSAKS_ANGGOTA_P_ANGGOTA

end if;

if exists(select 1 from sys.sysforeignkey where role='FK_TRANSAKS_PEGAWAI_C_PEGAWAI') then

    alter table transaksi_peminjaman

       delete foreign key FK_TRANSAKS_PEGAWAI_C_PEGAWAI

end if;

if exists(select 1 from sys.sysforeignkey where role='FK_TRANSAKS_TRANSAKSI_BUKU') then

    alter table transaksi_peminjaman

       delete foreign key FK_TRANSAKS_TRANSAKSI_BUKU

end if;

drop index if exists anggota.MEMILIKI_FK;

drop index if exists anggota.ANGGOTA_PK;

drop table if exists anggota;

drop index if exists buku.JENIS_BUKU_FK;

drop index if exists buku.BUKU_PK;

drop table if exists buku;

drop index if exists jenis_buku.JENIS_BUKU_PK;

drop table if exists jenis_buku;

drop index if exists pegawai.PEGAWAI_PK;

drop table if exists pegawai;

drop index if exists program_studi.PROGRAM_STUDI_PK;

drop table if exists program_studi;

drop index if exists transaksi_peminjaman.ANGGOTA_PINJAM_FK;

drop index if exists transaksi_peminjaman.TRANSAKSI_PINJAM_FK;

drop index if exists transaksi_peminjaman.PEGAWAI_CATAT_PEMINJAMAN_FK;

drop index if exists transaksi_peminjaman.TRANSAKSI_PEMINJAMAN_PK;

drop table if exists transaksi_peminjaman;

if exists(select 1 from sys.sysusertype where type_name='date') then

drop domain "date"

end if;

if exists(select 1 from sys.sysusertype where type_name='integer') then

drop domain "integer"

end if;

if exists(select 1 from sys.sysusertype where type_name='varchar100') then

drop domain varchar100

end if;

/*==============================================================*/

/\* Domain: "date"                                               */

/*==============================================================*/

create domain "date" as date;

/*==============================================================*/

/\* Domain: "integer"                                            */

/*==============================================================*/

create domain "integer" as integer;

/*==============================================================*/

/\* Domain: varchar100                                           */

/*==============================================================*/

create domain varchar100 as varchar(100);

/*==============================================================*/

/\* Table: anggota                                               */

/*==============================================================*/

create table anggota

(

kode_anggota         varchar(20)                    not null,

kode_prodi           integer                        not null,

nim                  integer                        not null,

nama                 varchar(30)                    not null,

tmpt_lahir           varchar(30)                    not null,

tgl_lahir            date                           not null,

email                varchar(50)                    not null,

constraint PK_ANGGOTA primary key (kode_anggota)

);

/*==============================================================*/

/\* Index: ANGGOTA_PK                                            */

/*==============================================================*/

create unique index ANGGOTA_PK on anggota (

kode_anggota ASC

);

/*==============================================================*/

/\* Index: MEMILIKI_FK                                           */

/*==============================================================*/

create index MEMILIKI_FK on anggota (

kode_prodi ASC

);

/*==============================================================*/

/\* Table: buku                                                  */

/*==============================================================*/

create table buku

(

kode_buku            "integer"                      not null,

id_jenis_buku        "integer"                      not null,

judul_buku           varchar100                     not null,

pengarang            varchar100                     null,

penerbit             varchar(50)                    null,

tahun_penerbit       numeric(4)                     null,

constraint PK_BUKU primary key (kode_buku)

);

/*==============================================================*/

/\* Index: BUKU_PK                                               */

/*==============================================================*/

create unique index BUKU_PK on buku (

kode_buku ASC

);

/*==============================================================*/

/\* Index: JENIS_BUKU_FK                                         */

/*==============================================================*/

create index JENIS_BUKU_FK on buku (

id_jenis_buku ASC

);

/*==============================================================*/

/\* Table: jenis_buku                                            */

/*==============================================================*/

create table jenis_buku

(

id_jenis_buku        "integer"                      not null,

nama_jenis_buku      varchar100                     not null,

constraint PK_JENIS_BUKU primary key (id_jenis_buku)

);

/*==============================================================*/

/\* Index: JENIS_BUKU_PK                                         */

/*==============================================================*/

create unique index JENIS_BUKU_PK on jenis_buku (

id_jenis_buku ASC

);

/*==============================================================*/

/\* Table: pegawai                                               */

/*==============================================================*/

create table pegawai

(

nomor_induk_pegawai  "integer"                      not null,

constraint PK_PEGAWAI primary key (nomor_induk_pegawai)

);

/*==============================================================*/

/\* Index: PEGAWAI_PK                                            */

/*==============================================================*/

create unique index PEGAWAI_PK on pegawai (

nomor_induk_pegawai ASC

);

/*==============================================================*/

/\* Table: program_studi                                         */

/*==============================================================*/

create table program_studi

(

kode_prodi           integer                        not null,

nama_prodi           varchar(50)                    not null,

constraint PK_PROGRAM_STUDI primary key (kode_prodi)

);

/*==============================================================*/

/\* Index: PROGRAM_STUDI_PK                                      */

/*==============================================================*/

create unique index PROGRAM_STUDI_PK on program_studi (

kode_prodi ASC

);

/*==============================================================*/

/\* Table: transaksi_peminjaman                                  */

/*==============================================================*/

create table transaksi_peminjaman

(

nomor_induk_pegawai  "integer"                      not null,

kode_buku            "integer"                      not null,

kode_anggota         varchar(20)                    not null,

kode_pinjam          "integer"                      not null,

tgl_pinjam           "date"                         not null,

tgl_kembali          "date"                         not null,

constraint PK_TRANSAKSI_PEMINJAMAN primary key (nomor_induk_pegawai, kode_buku, kode_anggota, kode_pinjam)

);

/*==============================================================*/

/\* Index: TRANSAKSI_PEMINJAMAN_PK                               */

/*==============================================================*/

create unique index TRANSAKSI_PEMINJAMAN_PK on transaksi_peminjaman (

nomor_induk_pegawai ASC,

kode_buku ASC,

kode_anggota ASC,

kode_pinjam ASC

);

/*==============================================================*/

/\* Index: PEGAWAI_CATAT_PEMINJAMAN_FK                           */

/*==============================================================*/

create index PEGAWAI_CATAT_PEMINJAMAN_FK on transaksi_peminjaman (

nomor_induk_pegawai ASC

);

/*==============================================================*/

/\* Index: TRANSAKSI_PINJAM_FK                                   */

/*==============================================================*/

create index TRANSAKSI_PINJAM_FK on transaksi_peminjaman (

kode_buku ASC

);

/*==============================================================*/

/\* Index: ANGGOTA_PINJAM_FK                                     */

/*==============================================================*/

create index ANGGOTA_PINJAM_FK on transaksi_peminjaman (

kode_anggota ASC

);

alter table anggota

add constraint FK_ANGGOTA_MEMILIKI_PROGRAM_ foreign key (kode_prodi)

      references program_studi (kode_prodi)

      on update restrict

      on delete restrict;

alter table buku

add constraint FK_BUKU_JENIS_BUK_JENIS_BU foreign key (id_jenis_buku)

      references jenis_buku (id_jenis_buku)

      on update restrict

      on delete restrict;

alter table transaksi_peminjaman

add constraint FK_TRANSAKS_ANGGOTA_P_ANGGOTA foreign key (kode_anggota)

      references anggota (kode_anggota)

      on update restrict

      on delete restrict;

alter table transaksi_peminjaman

add constraint FK_TRANSAKS_PEGAWAI_C_PEGAWAI foreign key (nomor_induk_pegawai)

      references pegawai (nomor_induk_pegawai)

      on update restrict

      on delete restrict;

alter table transaksi_peminjaman

add constraint FK_TRANSAKS_TRANSAKSI_BUKU foreign key (kode_buku)

      references buku (kode_buku)

      on update restrict

      on delete restrict;

avatar mencariijodoh
@mencariijodoh

1 Kontribusi 0 Poin

Diperbarui 1 tahun yang lalu

1 Jawaban:

<div>Ada info yang lebih general? seperti mengimportnya dengan apa. Sebelumnya file diexport dari mana? DBMS apa? sekarang mau dimasukkan kemana? pastikan versinya sudah sama juga</div>

avatar hilmanski
@hilmanski

2672 Kontribusi 2132 Poin

Dipost 1 tahun yang lalu

Tanggapan

Sebelum nya file sqlnya dibuat hasil dari generate powerdesigner, lalu mau import ke database melalui cmd

Login untuk ikut Jawaban