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

創(chuàng)新互聯(lián)公司致力于互聯(lián)網(wǎng)網(wǎng)站建設(shè)與網(wǎng)站營(yíng)銷,提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)站開發(fā)、seo優(yōu)化、網(wǎng)站排名、互聯(lián)網(wǎng)營(yíng)銷、微信平臺(tái)小程序開發(fā)、公眾號(hào)商城、等建站開發(fā),創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)策劃專家,為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制解決方案,幫助客戶在新的全球化互聯(lián)網(wǎng)環(huán)境中保持優(yōu)勢(shì)。
oracle基本操作語句(適合初學(xué)者)
oracle操作語句:
1.創(chuàng)建表
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.設(shè)置某列不可用,然后刪除
alter table 表名 set unused(列名);
alter table 表名 drop unused columns;
10.修改表名
rename 表名1 to 表名2
alter 表名1 rename to 表名2;
11.截?cái)啾?/p>
truncate table 表名;
12.截?cái)啾肀A粜锌臻g
truncate table 表名 resue storage;
13.查看表結(jié)構(gòu)
desc table 表名;
14.刪除表
drop table 表名;
15.插入記錄
例:insert into 表名 values(內(nèi)容1,內(nèi)容2,內(nèi)容3,內(nèi)容4);
16.帶參數(shù)對(duì)話方式插入行
例:insert into 表名 values(列名1,列名2);
insert into 表名 values(內(nèi)容1,內(nèi)容2);
17.插入某幾列記錄
insert into 表名(列名1,列名2) values(內(nèi)容1,內(nèi)容2);
18.為列插入空值(其列不能為not null)
insert into 表名 values(內(nèi)容1,null,null);
19.創(chuàng)建表(包括主鍵及外鍵設(shè)置)方法一
create table 表名(
列名1 類型
constraint pk_表名 primary key,
列名2 類型 not null,
列名3 類型
constraint fk_表名 reference 表名(列名),
列名3 類型
constraint ck_表名 check(列名3 in(''內(nèi)容1'',''內(nèi)容2'',''內(nèi)容3''))
);
20.查詢所有行
select * from 表名;
21.查詢某幾列
select 列名1,列名2 from 表名;
22.重復(fù)行消除
select distict 列名 from 表名;
23.where語句查詢
select * from 表名 where 條件 order by 列名;
(注:如number類型查出自動(dòng)按升序排列,如要按降序排列,則select * from 表名 where 條件 order by 列名 desc;)
24.創(chuàng)建表,方法二
create table 表名(
列名1 類型 primary key,
列名2 類型 not null,
列名3 類型 check(列名3 in('''','''','''')),
列名4 類型 refernce 表名(列名)
);
25.修改 列=‘?’的數(shù)據(jù)
update 表名 set (列=?) where 列=‘?’;
26.刪除行
delete from 表名 where 條件;
27.事務(wù)處理
--事務(wù)處理
update 表名
set 列名(日期) = ''30-5月-98''
where 條件;
savepoint mark1;
delete from 表名 where 條件;
savepoint mark2;
rollback to savepoint mark1;
rollback;
28.建立用戶user1,密碼為password
授予用戶connect,resource的權(quán)限
connect角色用于登錄
resource角色用于建表等.
connect system/manager
create user user1 identified by password;
grant connect,resource to password;
29.數(shù)據(jù)控制語言
connect scott/tiger
30.把對(duì)表1查詢和修改的權(quán)限授予user1
grant select,update on 表1 to user1;
31.把對(duì)表表1中列1和列2修改的權(quán)限授予user1
grant update(列1,列2) on 表1 to user1;
32.把對(duì)表表1查詢的權(quán)限授予用戶user1
并且user1用戶還可以把這個(gè)權(quán)限授予別的用戶(with grant option)
grant select on 表1 to user1 with grant option;
33.從用戶user1撤銷對(duì)表1查詢和修改的權(quán)限
revoke select,update on 表1 from user1;
修改oracle表中的字段使用"rename "關(guān)鍵字。
方法如下
修改字段名的方法:alter
table
表名
rename
column
原字段名
to
新字段名
修改表名的方法:alter
table
表名
rename
to
新表名
1.
spfile是參數(shù)文件。這個(gè)就相當(dāng)于你數(shù)據(jù)庫(kù)的一些配置的信息。scope=spfile,表明在數(shù)據(jù)庫(kù)下次啟動(dòng)的
時(shí)候生效。如果不加,表示立刻生效,下次啟動(dòng)依然有效。但有些參數(shù)是不能在數(shù)據(jù)庫(kù)運(yùn)行的狀態(tài)下修改的。
2.select...from...是標(biāo)準(zhǔn)的sql語句。也就是說,你select后面必須是表的列,from后面必須是表的名稱(當(dāng)然,視圖函數(shù)什么的就不多講了,講了你聽著也亂)。
system
不是表的名稱,所以你的語句是無效的。
alter
system
set
open_links=12,這句話你要按照英語翻譯過來。意思是將系統(tǒng)的open_links這個(gè)參數(shù),設(shè)置成12!而不是將system這個(gè)表修改掉。你看這句話里根本沒有table這個(gè)詞,當(dāng)然也就不能select。
你要用show
parameter
open就可以找到這個(gè)參數(shù)了。
你最好先去看看oracle基礎(chǔ)知識(shí)的書
看看tablespace的bigfile參數(shù)配置
一般來說,bigfile的表空間只有一個(gè)文件,而非大文件表空間的是可以有多個(gè)文件的,一般存儲(chǔ)的話,都是先存一個(gè)文件,滿了再寫下一個(gè)文件。
select
bigfile
from
dba_tablespaces
where
tablespace_name=\\'表空間名稱\\'
返回
yes
則是大文件表空間,返回no,就是普通的表空間(小文件的)
good
luck!
首先方法是使用RENAME關(guān)鍵字:
修改字段名:alter table 表名 rename column 現(xiàn)列名 to 新列名;
修改表名:alter table 表名 rename to 新表名
增加字段語法:alter table tablename add (column datatype [default value][null/not null],….);
說明:alter table 表名 add (字段名 字段類型 默認(rèn)值 是否為空);
例: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 (字段名 字段類型?默認(rèn)值 是否為空);
例: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是關(guān)鍵字)
例:alter table sf_InvoiceApply rename column PIC to NEWPIC;
表的重命名:
說明:alter table 表名 rename to? 新表名
例:alter table?sf_InvoiceApply rename to??sf_New_InvoiceApply;
本文題目:oracle如何改表名,修改表名oracle
本文網(wǎng)址:http://chinadenli.net/article9/dsippih.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、網(wǎng)站設(shè)計(jì)、建站公司、企業(yè)網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)