-- 查看当前用户
select user FROM dual;
--创建表空间
--datefile '地址'
--size
--autoextend on
--next
create tablespace test
datafile 'c:/data/test.dbf'
size 100m
autoextend on
next 10m;
--创建用户 default tablespace 默认表空间
create user c##user
identified by itcast
default tablespace waterboss;
--给新用户授权 grant dba to c##user;
grant dba to c##user;
--查看用户
select user FROM dual;
02-数据类型
-- 字符串类型
-- char(10)
-- varchar(10)
-- long
-- string
-- 数字类型
-- number(5)
-- number(5,2)
-- 时间类型
-- data ==> current_date
-- timestamp ==> current_timestamp
-- 把unix类型的时间戳 转化为data时间类型
-- SELECT date '1970-01-01' + NUMTODSINTERVAL(1711361758, 'SECOND') from dual;
03-表操作
-- 如果想要主键自增长 需要设置 自增序列
-- create sequence seq_userinfo
-- increment by 1
-- start with 1
-- nomaxvalue
-- nominvalue
-- cache 20;
-- 查看表结构
-- 在命令窗口 desc 表名
-- 在pl/sql中 SELECT DBMS_METADATA.GET_DDL('TABLE','XXX') FROM DUAL;
-- 注意: 表名必须大写
-- 1. 创建表(主键 没有自增长)
create table test
(
id number primary key,
name varchar2(100),
age number
);
-- 修改表结构
-- 2. 增加一个字段
-- ALTER TABLE 表名称 ADD(列名 1 类型 [DEFAULT 默认值],列名 1 类型 [DEFAULT 默