设为首页 加入收藏

TOP

Oracle表的管理
2015-07-24 10:34:40 来源: 作者: 【 】 浏览:1
Tags:Oracle 管理

1 表和列的命名规则
a. 必须以字母开头
b. 长度不能超过30个字符
c. 不能使用Oracle的保留字(关键字)
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;

4 修改表名
语法: 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 里程碑名称





】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇重新发现Oracle太美之glogin.sql 下一篇ORA-12514:TNS:监听程序当前无法..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·TCP/UDP协议_百度百科 (2025-12-26 12:20:11)
·什么是TCP和UDP协议 (2025-12-26 12:20:09)
·TCP和UDP详解 (非常 (2025-12-26 12:20:06)
·Python 教程 - W3Sch (2025-12-26 12:00:51)
·Python基础教程,Pyt (2025-12-26 12:00:48)