这里以创建一个学生表student为例子,表里面字段有id,name,sex,age,math,english,其中id是主键,其他的不为空,语法如下所示:
create table student(
id number(2) primary key,
name varchar(10) not null,
sex varchar(10) not null,
age number(3) not null,
math number(3) not null,
english number(3) not null
)
执行后会创建一个空表,可以用select * from student;查询表的内容,当然这时候只有几个字段。
接下来往里面添加几条数据:
insert into student values(1,'张三','男',18,88,90);
insert into student values(2,'李四','男',20,86,69);
insert into student values(3,'王五','男',19,59,74);
insert into student values(4,'赵六','男',17,59,81);
insert into student values(5,'田七','男',18,66,74);
insert into student values(6,'翠花','女',18,96,90);
这里一共添加了6条数据,执行查询语句看看表里面的内容:select * from student;,如下图所示

数据表创建成功。
博客以Oracle数据库为例,介绍了创建学生表student的方法,指定id为主键且其他字段不为空,创建出空表后,又向表中添加了6条数据,最后通过查询语句查看表内容,完成数据表创建。
870

被折叠的 条评论
为什么被折叠?



