php - 如何在 MySQL 数据库上使用“如果不存在”
问题描述
如何if not exists
在 MySQL 数据库中使用。
create schema if not exists appkasir;
use appkasir;
create table if not exists admin (
id int(11) not null auto_increment,
nama varchar(20) not null,
no_telp varchar(20) null,
alamat varchar(50) null,
email varchar(50) null,
primary key (id)
);
解决方案
你没有给出任何错误信息。我认为这不是主键的错误,if exists
但可能是主键的错误。
查看MySQL 参考资料。
尝试:
create schema if not exists appkasir;
use appkasir;
create table if not exists admin (
id int(11) not null auto_increment primary key,
nama varchar(20) not null,
no_telp varchar(20) null,
alamat varchar(50) null,
email varchar(50) null
);
推荐阅读
- r - 如果只有几个字符匹配,我可以匹配和替换数据吗?
- html - 使 SVG 文本元素绝对定位(即不占用空间)?
- typescript - 打字稿缺少扩展接口的类型定义
- intellij-idea - 在 IntelliJ 中为 shell 脚本调试设置断点
- python-xarray - 如何将等压相对湿度数据转换为二维数组形式?
- javascript - 有没有办法在 react-native-square-in-app-payments 中预填充字段(卡号、到期数据、cvv)以获得随机数?
- c# - 格式化 NodaTime 即时时包括尾随零?
- database - 在 jmeter 中重用查询
- java - Spring Cloud Contract:使用 URL 作为响应体参数
- python - 当一个人应该使用“axes”时使用matplotlib?