MySQL简单建表样例

实现下表并插入数据

name age class phonenumber
jim 13 A 123456789
mike 12 B 123654
lunce 15 C 521325
mimi 14 A 521463
kiki 16 E 852369
tom 18 B 145236

MySQL实现

#1.创建数据库
CREATE DATABASE mysu;
#2.使用所创建的数据库
USE mysu;
#3.创建学生表
CREATE TABLE IF NOT EXISTS Sstudentinfo (
	NAME VARCHAR(20) NOT NULL,
	age INT NOT NULL,
	class VARCHAR(20) NOT NULL,
	phonenumber INT NOT NULL
);
#4.插入数据
INSERT INTO Sstudentinfo VALUES
('Jim',15,'A','123456'),
('Pike',15,'B','336655'),
('kiki',14,'C','1456242'),
('poly',13,'D','156723');
#查看表格

SELECT * FROM Sstudentinfo;
#查询结果
+------+-----+-------+-------------+
| name | age | class | phonenumber |
+------+-----+-------+-------------+
| Jim  |  15 | A     |      123456 |
| Pike |  15 | B     |      336655 |
| kiki |  14 | C     |     1456242 |
| poly |  13 | D     |      156723 |
+------+-----+-------+-------------+

你可能感兴趣的:(Sql)