oracle01

–表名:不能以数字开头
–列名:不能以数字开头
–数据类型:数字(number),字符串,日期
–varchar2:可变长
–char:定长

–建学生表
create table student(
xuehao number(5),
name varchar2(6),
sex char(2),
birthday date);

–查询学生表所有信息
select * from student;
–修改列名(rename column)
alter table 表名 rename column 原列名 to 新列名;
alter table student rename column xuehao to id;
–修改数据(字符串)类型(modify)
alter table 表名 modify (列名 数据类型);
alter table student modify(name varchar2(50));
–查看表结构
点击command window,输入desc 表名 按回车键;
–增加一列
alter table 表名 add (列名 数据类型)
alter table student add (age number);
alter table student add(addr varchar2(50),height number(20));
–删除一列
alter table 表名 drop column 列名;
alter table student drop column height;
–修改表名(方法一)
rename 原表名 to 新表名;
rename student to sss;
–修改表名 (方法二);
alter table 原表名 rename to 新表名;
alter table sss rename to student;
–新增数据(向所有列)
insert into student values(…)
–删除表
drop table 表名;

猜你喜欢

转载自blog.csdn.net/xiaoxiaozhang11/article/details/104547166