1create database student1;
//student为数据库的名称
出现Query OK, 1 row affected (0.00 sec)表示建立成功
2接下来建立表
CREATE TABLE Student1
(Sno CHAR(9) PRIMARY KEY,
Sname CHAR(20) UNIQUE,
Ssex CHAR(2),
Sage SMALLINT,
Sdept CHAR(20)
);
出现Query OK, 0 rows affected (0.02 sec)表示表Student1建立成功;
3在表中插入数据
insert into student1(sno,sname,ssex,sage,sdept)
values('201215121','李勇','男','20','cs');
insert into student1(sno,sname,ssex,sage,sdept)
values('201215122','刘晨','女','19','cs');
insert into student1(sno,sname,ssex,sage,sdept)
values('201215123','王敏','女','18','ma');
insert into student1(sno,sname,ssex,sage,sdept)
values('201215125','张立','男','19','is');
插入完成可以查看一下
输入
select *from student1;
会看到
+-----------+-------+------+------+-------+
| Sno | Sname | Ssex | Sage | Sdept |
+-----------+-------+------+------+-------+
| 201215121 | 李勇 | 男 | 20 | cs |
| 201215122 | 刘晨 | 女 | 19 | cs |
| 201215123 | 王敏 | 女 | 18 | ma |
| 201215125 | 张立 | 男 | 19 | is |
+-----------+-------+------+------+-------+
则插入数据成功;
欢迎大佬指教,有不懂的小可爱可以私信q2651877067,很高兴为你解答QwQ!!!