天天看點

sysbase/oracle下建立使用者及表方法

Oracle資料庫

1.建立表空間hutao_charge

以下建立hutao_charge表空間的腳本中,1600M表示資料空間初始值,50M表示空間自動擴充值。當1600M空間用完後,會自動擴充,每一次擴充增加50M, 最大空間不受限。

connect hutao_smap/[email protected];
create tablespace hutao_charge
datafile '/hutaodata/hutao_file2/hutao_charge.dbf'
size 1600 M REUSE AUTOEXTEND ON NEXT 50 M MAXSIZE UNLIMITED DEFAULT
STORAGE ( INITIAL 64K NEXT 4M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0);
commit;
           

2 建立使用者和表空間

connect hutao_smap/[email protected];
drop user hutao_charge cascade ; 
create user hutao_charge identified by hutao_charge 
default tablespace hutao_charge 
temporary tablespace hutao_temp profile default ; 
grant connect to hutao_charge ; 
grant dba to hutao_charge ; 
drop user hutao_bill cascade ; 
create user hutao_bill identified by hutao_bill 
default tablespace hutao_charge 
temporary tablespace hutao_temp profile default ; 
grant connect to hutao_bill ; 
grant dba to hutao_bill ;
commit;
           

3 修改hutao_bill,hutao_charge使用者的密碼為hutao_smap

connect hutao_smap/[email protected];
alter user hutao_bill identified by hutao_smap;
alter user hutao_charge identified by hutao_smap;
commit
           

Sybase資料庫

1 建立資料庫hutao_charge和hutao_bill

use master
go
dump tran master with no_log
go
if exists(select name from master..sysdatabases where name = 'hutao_charge')
  drop database hutao_charge
go
if exists(select name from master..sysdatabases where name = 'hutao_bill')
  drop database hutao_bill
go

create database hutao_charge on hutaodatadev = 2000 log on hutaodatalog = 500
go

if exists(select name from master..sysdevices where name = 'hutao_charge_bak')
  exec sp_dropdevice hutao_charge_bak
go

exec sp_addumpdevice 'disk', 'hutao_charge_bak', '/data/hutao_charge_bak.dat'
go

create database hutao_bill on hutaodatadev = 2000 log on hutaodatalog = 500
go

if exists(select name from master..sysdevices where name = 'hutao_bill_bak')
  exec sp_dropdevice hutao_bill_bak
go

exec sp_addumpdevice 'disk', 'hutao_bill_bak', '/data/hutao_bill_bak.dat'
go
           

2 建立使用者hutao_charge和hutao_bill

use hutao_charge
go

if not (exists (select 1 from master..syslogins where name = 'hutao_charge'))
begin
  exec sp_addlogin hutao_charge,hutao_charge,hutao_charge
end
go

if not exists (select 1 from dbo.sysusers where name = 'hutao_charge' and uid < 16382)
    exec sp_adduser hutao_charge
go

use hutao_bill
go

if not (exists (select 1 from master..syslogins where name = 'hutao_bill'))
begin
  exec sp_addlogin hutao_bill,hutao_bill,hutao_bill
end
go

if not exists (select 1 from dbo.sysusers where name = 'hutao_bill' and uid < 16382)
    exec sp_adduser hutao_bill
go
           

3 修改hutao_bill,hutao_charge使用者的密碼為hutao_smap

用hutao_bill/hutao_bill登入

exec sp_password hutao_bill(使用者名), hutao_smap(密碼), hutao_bill
go
           

用hutao_charge/hutao_charge登入

exec sp_password hutao_charge, hutao_smap, hutao_charge
go