oracle基本建表语句练习
2014-05-29 14:02
218 查看
//创建表--学生表
create table student(
id number(9) not null primary key,
name varchar2(40) not null,
age number(9),
classname varchar2(40) not null
)
//增加列
alter table student add address varchar2(40)
alter table student add birthday date not null
//删除列
alter table student drop column address
alter table student drop column classname
//修改列的名称
alter table student modify address addresses varchar2(40)
//插入
insert into student values(1,'mary',19,to_date('01-01-1995','MM-DD-YYYY'));
insert into student values(2,'john',20,to_date('01-01-1994','MM-DD-YYYY'));
insert into student values(3,'tom',21,to_date('01-01-1993','MM-DD-YYYY'));
select * from student
SELECT COUNT(*) FROM STUDENT
//创建序列实现id自增
create sequence stu_seq increment by 1 start with 4 MAXVALUE 99 NOCYCLE NOCACHE
//运用序列实现id自增,序列名.nextval
insert into student values(stu_seq.nextval,'tokea',23,to_date('02-05-1991','MM-DD-YYYY'))
insert into student values(stu_seq.nextval,'joy',25,to_date('02-05-1989','MM-DD-YYYY'))
insert into student values(stu_seq.nextval,'yeak',23,to_date('29-08-1991','MM-DD-YYYY'))
//删除某一行数据
delete from 表名 where id=4
//查询年龄不在19,20之间的学生姓名
select name from student where age not between 19 and 20
//模糊查询,首字母为j的学生姓名
select name from student where name like 'j%'
//oracle实现分页
select ×from(
select t.*,rownum from table1 t where condition)
where rownum>(pagen)
create table student(
id number(9) not null primary key,
name varchar2(40) not null,
age number(9),
classname varchar2(40) not null
)
//增加列
alter table student add address varchar2(40)
alter table student add birthday date not null
//删除列
alter table student drop column address
alter table student drop column classname
//修改列的名称
alter table student modify address addresses varchar2(40)
//插入
insert into student values(1,'mary',19,to_date('01-01-1995','MM-DD-YYYY'));
insert into student values(2,'john',20,to_date('01-01-1994','MM-DD-YYYY'));
insert into student values(3,'tom',21,to_date('01-01-1993','MM-DD-YYYY'));
select * from student
SELECT COUNT(*) FROM STUDENT
//创建序列实现id自增
create sequence stu_seq increment by 1 start with 4 MAXVALUE 99 NOCYCLE NOCACHE
//运用序列实现id自增,序列名.nextval
insert into student values(stu_seq.nextval,'tokea',23,to_date('02-05-1991','MM-DD-YYYY'))
insert into student values(stu_seq.nextval,'joy',25,to_date('02-05-1989','MM-DD-YYYY'))
insert into student values(stu_seq.nextval,'yeak',23,to_date('29-08-1991','MM-DD-YYYY'))
//删除某一行数据
delete from 表名 where id=4
//查询年龄不在19,20之间的学生姓名
select name from student where age not between 19 and 20
//模糊查询,首字母为j的学生姓名
select name from student where name like 'j%'
//oracle实现分页
select ×from(
select t.*,rownum from table1 t where condition)
where rownum>(pagen)
相关文章推荐
- oracle 基本语句练习(一) where, between ,null, like,转义字符,order by
- oracle 基本语句练习(四) SQL1999 语法规范 cross join ,等值连接,不等值连接,自连接与外连接
- oracle中scott用户下四个基本表SQL语句练习
- oracle 基本语句练习(一) where, between ,null, like,转义字符,order by
- Oracle中scott用户下基本表练习SQL语句
- MYSQL基本查询语句练习1--用到的表和建表语句
- oracle 基本操作练习——简单的sql语句
- Oracle轻松取得建表和索引的DDL语句
- Oracle sql语句练习
- oracle基本操作语句
- Oracle基本语句(1)
- Oracle 9i轻松取得建表和索引的DDL语句
- Oracle PL/SQL:IF语句的基本使用
- Oracle 9i轻松取得建表和索引的DDL语句
- Oracle 基本建表语句
- oracle 基本sql语句
- oracle基本语句学习
- 如何查看Oracle数据表的建表语句
- oracle DBA 基本语句
- Oracle 基本建表语句