本地环境连接oracle数据库以及入门使用

使用命令行进入oracle
sqlplus root/root

  

 

 口令就是密码,当初设置的,我的是root

--查询数据库的表空间
select tablespace_name from dba_data_files;

--创建表空间
testspace:表空间名称
datafile:指定dbf文件在linux的存放地址
size:可以理解为文件初始化大小
autoextend:当size堆满后,每次自动扩展的大小
create tablespace testspace datafile 'D:\app\Yourheart\test001.dbf' size 10240M autoextend on next 1024M maxsize 10240M;

--创建用户
create user test identified by test default tablespace testspace;

--授权用户
grant create session to test;
grant create table to test;
grant create tablespace to test;
grant create view to test;
grant connect,resource,dba to test;
alter user test default tablespace testspace;

  

--建表
CREATE TABLE public_net(
 id number(12),
 net_name varchar2(255),
 net_address varchar2(255),
 net_status varchar2(5)
)
--给表加注释
COMMENT ON TABLE test.public_net IS '公有网站记录';

--字段加注释
COMMENT ON column test.public_net.id IS '主键';

COMMENT ON column test.public_net.net_name IS '地址名称';
COMMENT ON column test.public_net.net_address IS '地址';
COMMENT ON column test.public_net.net_status IS '地址状态';

SELECT  *  FROM  test.public_net

INSERT INTO public_net(id,net_name,net_address,net_status)
values('1111','123','456','1')

  

 

posted @ 2022-09-15 16:19  不忘初心2021  阅读(144)  评论(0编辑  收藏  举报