数据库---知识点整理

1.SQL、T-SQL、PL/SQL之间的区别:SQL 指结构化查询语言,全称是 Structured Query Language,SQL 让你可以访问和处理数据库,包括数据插入、查询、更新和删除。T-SQL 即 Transact-SQL,是 SQL 在 Microsoft SQL Server 上的增强版,它是用来让应用程式与 SQL Server 沟通的主要语言。T-SQL 提供标准 SQL 的 DDL 和 DML 功能,加上延伸的函数、系统预存程序以及程式设计结构(例如 IF 和 WHILE)让程式设计更有弹性。PLSQL 是Oracle公司在SQL基础上进行扩展而成的一种过程语言。PLSQL提供了典型的高级语言特 性,包括封装,例外处理机制,信息隐藏,面向对象等;并把最新的编程思想带到了数据库服务器和工具 集中。对于我来言PLSQL就是IDEA+ORACLE集成在一起了。

 

 

2.Oracle表操作
(1)创建表
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
根据已有的表创建新表:
A:select * into table_new from table_old (使用旧表创建新表)
B:create table tab_new as select col1,col2… from tab_old definition only<仅适用于Oracle>
(2)删除表
drop table tabname
(3)重命名表
说明:alter table 表名 rename to 新表名
eg:alter table tablename rename to newtablename
(4)增加字段
说明:alter table 表名 add (字段名 字段类型 默认值 是否为空);
例:alter table tablename add (ID int);
eg:alter table tablename add (ID varchar2(30) default '空' not null);
(5)修改字段
说明:alter table 表名 modify (字段名 字段类型 默认值 是否为空);
eg:alter table tablename modify (ID number(4));
(6)重名字段
说明:alter table 表名 rename column 列名 to 新列名 (其中:column是关键字)
eg:alter table tablename rename column ID to newID;
(7)删除字段
说明:alter table 表名 drop column 字段名;
eg:alter table tablename drop column ID;
(8)添加主键
alter table tabname add primary key(col)
(9)删除主键
alter table tabname drop primary key(col)
(10)创建索引
create [unique] index idxname on tabname(col….)
(11)删除索引
drop index idxname
注:索引是不可更改的,想更改必须删除重新建。
(12)创建视图
create view viewname as select statement
(13)删除视图
drop view viewname

 

 

 

 

posted @ 2022-04-07 20:04  Nafisa·Nur  阅读(65)  评论(0)    收藏  举报