Linux 环境下Oracle安装与调试(二)之创建数据库,数据增删改

1

、介绍 数据库,数据表,记录,字段,和对数据表的操作增删改(create,alter,drop)

下面针对具体的表来说明一下:


wKioL1NXcAGBV3M9AAAdijhBRVU646.png

#sysplus  /nolog

SQL>startup

SQL>conn /as sysdba

#查看oracle现有账号

SQL> select username,account_status from dba_users;

wKiom1NXdNGBn1zPAABKpO1e_rk794.png

#下面用SCOTT账号进行演示操作,

#oracle 11.2默认锁定SCOTT,需要解锁

SQL> alter user scott account unlock;

#设置scott账号密码为tiger

SQL>alter user scott identified by tiger;

#重新输出一下现有oracle账号,发现scott已经open

SQL> select username,account_status from dba_users;

#用scott连接

SQL> conn scott/tiger

Connected.

#查看当前用户

SQL> show user

USER is "SCOTT"

create创建#scott默认有四个表,新建一个学生表

SQL> create table students(id integer,name varchar(25));

Table created.

#查看学生表字段类型

SQL> DESC students

Name                                      Null?    Type

----------------------------------------- -------- ----------------------------

ID                                                 NUMBER(38)

NAME                                         VARCHAR2(25)

insert into插入#插入3条记录

SQL> insert into students values(1,'Jason');

SQL> insert into students values(2,'Charley');

SQL> insert into students values(3,'Evan');

#插入其中2个字段的值

SQL> INSERT INTO xue_sheng(id,nian_ling) VALUES(4 , 25);

#输出表中所有记录

SQL> select * from students;


       ID NAME

---------- -------------------------

        1 Jason

        2 Charley

        3 Evan

alter增加字段#在现有表中增加字段,修改操作ALTER,

SQL> ALTER TABLE students ADD age number;

Table altered.

wKiom1NXfNrwiu84AAAoAizNRBI724.png

update 更新数据

#更新3条记录

SQL> update students set age=27 where id=1;

SQL> update students set age=30 where id=2;

SQL> update students set age=21 where id=3;

输出表

wKiom1NXgB_B_mM_AAARrcLEPDk030.png

delete from删除记录

SQL> delete from students where id=4;

alter drop删除字段

#删除年龄字段

SQL> alter table students drop column age;

drop table 删除表

SQL>drop table students;


2、字段数据类型

wKioL1NXtVTRC7TKAACQwHUhobc083.png

wKiom1NXtX6RbdgBAAChZzKDKbE472.png

wKioL1NXtVSCLzHVAAAoKKZsJfA193.png

wKiom1NXtX-D7G3eAACpYzvLdsA639.png

wKioL1NXtVbiyya3AACm4ioywec591.png

wKiom1NXtYDCMVWSAACn7C3XA_4901.png

wKioL1NXtVeBxWc0AACV2UQYNEU572.png

wKiom1NXtYHhgOj0AABxOBsmnN4746.png

wKioL1NXtVeDJp_MAACGJ5hk3BY202.png

wKiom1NXtYGDZfBhAAAs1e9tI_s082.png

wKioL1NXtVjCXNvdAABuG71l2SY609.png


你可能感兴趣的:(oracle,account,identified)