这个mysql数据库语言怎么用代码写出来?
发布网友
发布时间:2022-05-03 06:13
我来回答
共2个回答
热心网友
时间:2022-05-03 07:42
USE db_abc;
CREATE TABLE department3(
id INT AUto_INCREMENT PRIMARY KEY COMMENT ’自增,主键
dept_name VARCHAR(20) NOT NULL UNIQUE COMMENT ‘唯一键
dept_phone CHAR(13) COMMENT ‘部门电话’,
dept_memo VARCHAR(100)COMMENT ‘ 备注
);
SHOW TABLES;
-#-------创建员工表-------
CREATE TABLE staffer(
id INT AUTO INCREMENT PRIMARY KEY,
staff_name VARCHAR(15) NOT NULL,
dept id INT
sex ENUM(‘F’,‘M’) DEFAULT ‘F
phone CHAR(11),
salary DOUBLE(9,1) CHECK(salary > 0 AND salary <= 100000),
staff_ memo VARCHAR(200) ,
FOREIGN KEY(dept_ id) REFERENCES departmeny(id)
);
#----顾客表----
CREATE table customer1(
costomer_ id INT AUTO_ _INCREMENT PRIMARY KEY COMMENT ‘主键’,
customer_ name VARCHAR(10) NOT NULL COMMENT ‘顾客名字’,
sex enum(‘n’,‘v’) DEFAULT ‘N’ COMMENT ‘性别n男v女’,
dirthday datetime COMMENT ‘出生 日期’,
hobby SET( ‘music’, ‘ball’) COMMENT ‘ 爱好’
consumption_ _amount DOUBLE(5,1) UNSIGNED DEFAULT 0 COMMENT ‘消费金额
mender_ _balance DECIMAL(5,2) UNSIGNED DEFAULT 0 COMMENT ‘会员余额’,
photo VARCHAR(250),
address json
);
--------复制表结构--------------
CREATE TABLE IF NOT EXISTS staffer_ _bak
LIKE Jstaffer;
DESC staffer. _bak;
DESC staffer_ bak;|
热心网友
时间:2022-05-03 09:00
不知道表和字段名,我就随意了啊:
use db_shop;
update 表
set 工号 = '32'
where 姓名 = '张红';
delete 员工表 where 姓名 = '尼古拉斯·赵四'