Oracle表的管理

版权声明:本文为博主原创文章,未经博主同意不得转载。

https://blog.csdn.net/u011685627/article/details/25340057

1 表和列的命名规则
 a. 必须以字母开头
 b. 长度不能超过30个字符
 c. 不能使用Oracle的保留字(keyword)
 d. 仅仅能使用例如以下字符A-Z,a-z,0-9,$,#

2 创建表
 语法:create table 表名 (列名 数据类型。列名 数据类型,...)
 SQL> create table Student (StuNo number(10),Gender char(4),Birthday date,Address varchar(20));
 
3 加入列
 语法:alter table Student add (列名 数据类型)
 SQL> alter table Student add (ClassNo char(15));
 
4 改动列的长度
 语法:alter table Student modify (列名 数据类型)
 SQL> alter table Student modify (Address varchar(15));
 
5 改动列的类型
 语法: alter table Student modify (列名 数据类型)
 SQL> alter table Student modify (Address varchar(15));
 
6 删除列
 语法: alter table Student drop column 列名
 SQL> alter table Student drop column Address;
 
7 改动表名
 语法: rename 原表名 to 新表名
 SQL> rename Student to Student1。
 
8 删除表
 语法: drop table 表名
 SQL> drop table Student;
 
9 插入值
 语法:insert into Student values ("值1","值2","值3","值4","值5")
 SQL> insert into Student values ("09110120","男","27-5-1987","中国北京");
 
10 更改默认日期格式
 Oracle中默认的日期格式是“dd-MON-YY”
 语法:alter session set nls_date_format = '新日期格式'
 SQL> alter session set nls_date_format = 'yyyy-mm-dd'
 
11 改动记录
 语法:update 表名 set 列名='值1'
 SQL> update Student set Address = '中国上海' where StuNo = '09110120';
 
12 删除表中的信息
 语法:delete from 表名
 SQL> delete from Student
 
14 删除表中的某一条记录
 语法:delete from 表名 where 条件
 SQL> delete from Student where StuNo='09110120';
 
15  删除表中的信息(无法回滚)
 语法:truncate table 表名
 SQL> truncate table Student;
 特点:删除表中的信息,速度快。

因为不写日志,所以无法回滚找回删除的数据
 
16 创建里程碑
 SQL>
savepoint 里程碑名称
 
 
 
 
 
 

posted @ 2019-05-12 15:10  ldxsuanfa  阅读(110)  评论(0编辑  收藏  举报