oracle忘记密码修改表列和表创建

2020-02-04  本文已影响0人  简兮_d116

1.登陆管理员用户 修改密码

alter user 用户名 identified by 新密码

Oracle12C 用户名要C##开头;

增加字段的语句很简单,以用户身份连接oracle服务:

alter table tablename add(colnamecoltype);  # 填上表名、字段名、字段类型

修改字段顺序前,查看表中各字段的顺序:

  首先,查看表对应的id:

select object_id from all_objects where owner='user' and object_name='tablename'; # 填上表的所有者、表名

  然后,查看表中各字段的顺序:

select obj#,col#,name from sys.col$ where obj#=objectid # 填上刚刚查到的表id

  再以sysdba身份连接oracle服务,修改字段顺序,否则可能会报权限不够:

update sys.col$ setcol#=new where name='col name' and obj#=objectid # 填上字段新的顺序、字段名、表id

  值得注意的一点是,更新完字段顺序后,若直接插入数据,还是按旧的字段顺序插入的,需要指定插入的字段或者重启oracle。

创建表

-- Create table

create table FACTS_TAX_DUES

(

  tyshxydm VARCHAR2(200) not null,

  name    VARCHAR2(200),

  money    NUMBER(10) not null

)

tablespace USERS

  pctfree 10

  initrans 1

  maxtrans 255;

-- Add comments to the table

comment on table FACTS_TAX_DUES

  is '税款金额表';

-- Add comments to the columns

comment on column FACTS_TAX_DUES.tyshxydm

  is 'id';

comment on column FACTS_TAX_DUES.name

  is '公司名称';

comment on column FACTS_TAX_DUES.money

  is '金额';

-- Create/Recreate primary, unique and foreign key constraints

alter table FACTS_TAX_DUES

  add primary key (TYSHXYDM)

  using index

  tablespace USERS

  pctfree 10

  initrans 2

  maxtrans 255;

上一篇 下一篇

猜你喜欢

热点阅读