oracle如何改表名,修改表名oracle

oracle教程

//*************

创新互联公司致力于互联网网站建设与网站营销,提供成都做网站、网站设计、网站开发、seo优化、网站排名、互联网营销、微信平台小程序开发、公众号商城、等建站开发,创新互联公司网站建设策划专家,为不同类型的客户提供良好的互联网应用定制解决方案,帮助客户在新的全球化互联网环境中保持优势。

oracle基本操作语句(适合初学者)

oracle操作语句:

1.创建表

create table 表名(

列名1 类型,

列名2 类型

);

2.修改类属性

alter table 表名 modify(列名 类型);

3.添加列

alter table 表名 add(列名 类型);

4.添加主键约束和非空约束

alter table 表名 add constraint pk_表名 primary key(列名);

alter table 表名 modify(列名 not null);

5.删除主键约束

alter table 表名 drop primary key;

alter table 表名 drop constraint pk_表名;

6.失效约束

alter table 表名 disable primary key;

alter table 表名 disable constraint pk_表名;

7.有效约束

alter table 表名 enable primary key;

alter table 表名 enable constraint pk_表名;

8.删除列

alter table 表名 drop column 列名;

9.设置某列不可用,然后删除

alter table 表名 set unused(列名);

alter table 表名 drop unused columns;

10.修改表名

rename 表名1 to 表名2

alter 表名1 rename to 表名2;

11.截断表

truncate table 表名;

12.截断表保留行空间

truncate table 表名 resue storage;

13.查看表结构

desc table 表名;

14.删除表

drop table 表名;

15.插入记录

例:insert into 表名 values(内容1,内容2,内容3,内容4);

16.带参数对话方式插入行

例:insert into 表名 values(列名1,列名2);

insert into 表名 values(内容1,内容2);

17.插入某几列记录

insert into 表名(列名1,列名2) values(内容1,内容2);

18.为列插入空值(其列不能为not null)

insert into 表名 values(内容1,null,null);

19.创建表(包括主键及外键设置)方法一

create table 表名(

列名1 类型

constraint pk_表名 primary key,

列名2 类型 not null,

列名3 类型

constraint fk_表名 reference 表名(列名),

列名3 类型

constraint ck_表名 check(列名3 in(''内容1'',''内容2'',''内容3''))

);

20.查询所有行

select * from 表名;

21.查询某几列

select 列名1,列名2 from 表名;

22.重复行消除

select distict 列名 from 表名;

23.where语句查询

select * from 表名 where 条件 order by 列名;

(注:如number类型查出自动按升序排列,如要按降序排列,则select * from 表名 where 条件 order by 列名 desc;)

24.创建表,方法二

create table 表名(

列名1 类型 primary key,

列名2 类型 not null,

列名3 类型 check(列名3 in('''','''','''')),

列名4 类型 refernce 表名(列名)

);

25.修改 列=‘?’的数据

update 表名 set (列=?) where 列=‘?’;

26.删除行

delete from 表名 where 条件;

27.事务处理

--事务处理

update 表名

set 列名(日期) = ''30-5月-98''

where 条件;

savepoint mark1;

delete from 表名 where 条件;

savepoint mark2;

rollback to savepoint mark1;

rollback;

28.建立用户user1,密码为password

授予用户connect,resource的权限

connect角色用于登录

resource角色用于建表等.

connect system/manager

create user user1 identified by password;

grant connect,resource to password;

29.数据控制语言

connect scott/tiger

30.把对表1查询和修改的权限授予user1

grant select,update on 表1 to user1;

31.把对表表1中列1和列2修改的权限授予user1

grant update(列1,列2) on 表1 to user1;

32.把对表表1查询的权限授予用户user1

并且user1用户还可以把这个权限授予别的用户(with grant option)

grant select on 表1 to user1 with grant option;

33.从用户user1撤销对表1查询和修改的权限

revoke select,update on 表1 from user1;

oracle中怎么更改表中字段名?

修改oracle表中的字段使用"rename "关键字。

方法如下

修改字段名的方法:alter

table

表名

rename

column

原字段名

to

新字段名

修改表名的方法:alter

table

表名

rename

to

新表名

oracle数据库怎么修改表名

1.

spfile是参数文件。这个就相当于你数据库的一些配置的信息。scope=spfile,表明在数据库下次启动的

时候生效。如果不加,表示立刻生效,下次启动依然有效。但有些参数是不能在数据库运行的状态下修改的。

2.select...from...是标准的sql语句。也就是说,你select后面必须是表的列,from后面必须是表的名称(当然,视图函数什么的就不多讲了,讲了你听着也乱)。

system

不是表的名称,所以你的语句是无效的。

alter

system

set

open_links=12,这句话你要按照英语翻译过来。意思是将系统的open_links这个参数,设置成12!而不是将system这个表修改掉。你看这句话里根本没有table这个词,当然也就不能select。

你要用show

parameter

open就可以找到这个参数了。

你最好先去看看oracle基础知识的书

如何修改Oracle 表空间名称tablespace name

看看tablespace的bigfile参数配置

一般来说,bigfile的表空间只有一个文件,而非大文件表空间的是可以有多个文件的,一般存储的话,都是先存一个文件,满了再写下一个文件。

select

bigfile

from

dba_tablespaces

where

tablespace_name=\\'表空间名称\\'

返回

yes

则是大文件表空间,返回no,就是普通的表空间(小文件的)

good

luck!

oracle中怎么更改表中字段名

首先方法是使用RENAME关键字:

修改字段名:alter table 表名 rename column 现列名 to 新列名;

修改表名:alter table 表名 rename to 新表名

增加字段语法:alter table tablename add (column datatype [default value][null/not null],….);

说明:alter table 表名 add (字段名 字段类型 默认值 是否为空);

例:alter table sf_users add (HeadPIC blob);

例:alter table sf_users add (userName varchar2(30) default '空' not null);

修改字段的语法:alter table tablename modify (column datatype [default value][null/not null],….);

说明:alter table 表名 modify (字段名 字段类型 默认值 是否为空);

例:alter table sf_InvoiceApply modify (BILLCODE number(4));

删除字段的语法:alter table tablename drop (column);

说明:alter table 表名 drop column 字段名;

例:alter table sf_users drop column HeadPIC;

字段的重命名:

说明:alter table 表名 rename  column  列名 to 新列名   (其中:column是关键字)

例:alter table sf_InvoiceApply rename column PIC to NEWPIC;

表的重命名:

说明:alter table 表名 rename to  新表名

例:alter table sf_InvoiceApply rename to  sf_New_InvoiceApply;


新闻名称:oracle如何改表名,修改表名oracle
分享路径:http://scyanting.com/article/dsippih.html