日期:2014-05-16  浏览次数:20357 次

oracle数据库笔记---pl/sql的基础使用方法
2.pl/sql的使用:创建表:
a.输入账户,密码进入后,
b.在左侧下拉框选择All objects,中的tables有很多,是系统自带的表;
在左侧下拉框选择My objects,中的tables没有表存在,在这里可以创建自己的表
c.创建自己的表:tables上,右键new一个新表;在General标签下,Name:users,注意这里不能
填写user,因为user是关键字,columns是字段:创建id type:number name:varchar2(10),
pwd type:varchar2(10),点击keys添加主键,给主键起名为pk_users type:Primary 选上
Enabled.
d.点击view sql查看sql语句:
-- Create table
create table USERS
(
ID NUMBER not null,
NAME NVARCHAR2(10),
PWD NVARCHAR2(10)
)
tablespace TEST
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table USERS
add constraint PK_USES primary key (ID)
using index
tablespace TEST
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
--------------------------
3.往新建的users表中添加数据
在左侧的tables中选中users表,右键,选择edit data:
添加数据 id 1 name:admin pwd:123
id 2 name:user pwd:123
每添加一条数据:就点击一下菜单栏的向下的一个箭头,表示提交事务
-------------------------------------
4.从新建的表users中查询数据:
在左侧的tables中选中users表,右键,选择query data:
-----------------------------------------------------
5.更改新建表users的表结构
在左侧的tables中选中users表,右键,选择Edit:
--------------------------------------------
6.在新建表users中执行sql语句:
在左侧的tables中选中users表,右键,选择query data:
在sql视图中写sql语句,写完后,点击一个齿轮的图标执行;
----------------------