oracl数据库的常用知识
2015-08-14 00:19
239 查看
cmd的解锁命令
sqlplus / as sysdba
SQL>alter user scott acount unlock;使其未锁定
SQL>alter user scott acount identified by 密码;修改其密码
SQL> conn scott/密码;根据新的密码和用户名连接上数据库;
//创建表
create table 表名(列名 类名类型,列名 类名类型,列名 类名类型,,,,,);
//更新表
update 表名 set 列名=修改内容 where 主键=对应的值;
//修改表结构
alter table 表名 add 增加的列名 列名类型;
//删除表中某条记录
delete from 表名 where 列名 = 值;
//删除表
drop table 表名;
//删除表中的某一列
alter table 表名 drop column 列名;
//删除主键约束
alter table 表名 drop primary key;
//添加主键约束
alter table 表名 modify (列名 列名类型 primary key);
//添加唯一约束
alter table 表名 add constraint 自定义约束名 unique(列名);
//删除唯一约束
alter table 表名 drop constraint 约束名;
//添加检查约束
alter table 表名 add constraint 约束名 check (sex in('男','女'));
//约束重命名
alter table 表名 rename constraint 原约束名 to 改后的约束名;
//默认约束
alter table 表名 modify 列名 列名类型 default 约束条件;
//创建学生表与课程表的映射表-----联合主键
create table student (
sno varchar2(20),
constraint fk_student _sno references student (sno),
cno varchar2(20),
constraint fk_student _cno references course (cno),
grade number consteaint ck_grade check(grade between 0 and 100),
constraint fk_cno_sno primary key (sno,cno)
);
//标的简单查询
select * from 表名 ;
//去掉重复行查询
select distinct 列名 from 表名;
//查看表结构
desc 表名;
sqlplus / as sysdba
SQL>alter user scott acount unlock;使其未锁定
SQL>alter user scott acount identified by 密码;修改其密码
SQL> conn scott/密码;根据新的密码和用户名连接上数据库;
//创建表
create table 表名(列名 类名类型,列名 类名类型,列名 类名类型,,,,,);
//更新表
update 表名 set 列名=修改内容 where 主键=对应的值;
//修改表结构
alter table 表名 add 增加的列名 列名类型;
//删除表中某条记录
delete from 表名 where 列名 = 值;
//删除表
drop table 表名;
//删除表中的某一列
alter table 表名 drop column 列名;
//删除主键约束
alter table 表名 drop primary key;
//添加主键约束
alter table 表名 modify (列名 列名类型 primary key);
//添加唯一约束
alter table 表名 add constraint 自定义约束名 unique(列名);
//删除唯一约束
alter table 表名 drop constraint 约束名;
//添加检查约束
alter table 表名 add constraint 约束名 check (sex in('男','女'));
//约束重命名
alter table 表名 rename constraint 原约束名 to 改后的约束名;
//默认约束
alter table 表名 modify 列名 列名类型 default 约束条件;
//创建学生表与课程表的映射表-----联合主键
create table student (
sno varchar2(20),
constraint fk_student _sno references student (sno),
cno varchar2(20),
constraint fk_student _cno references course (cno),
grade number consteaint ck_grade check(grade between 0 and 100),
constraint fk_cno_sno primary key (sno,cno)
);
//标的简单查询
select * from 表名 ;
//去掉重复行查询
select distinct 列名 from 表名;
//查看表结构
desc 表名;
相关文章推荐
- SQL 增删改查(详细)
- Oracle 11g 导库导不出空表问题
- mysql修改默认的环境的字符集为utf-8
- 如何统计全天各个时间段产品销量情况(sqlserver)
- SQL Server数据库安装时常见问题解决方案集锦
- SQL编程之子查询及注意事项
- 详解SQL Server数据库链接查询的方式
- 简析SQL Server数据库用视图来处理复杂的数据查询关系
- SQL Server多表查询优化方案集锦
- Oracle数据库优化策略总结篇
- 简析Oracle数据库常见问题及解决方案
- MySQL备份与恢复之保证数据一致性(5)
- 解析SQL Server 视图、数据库快照
- MYSQL 创建函数出错的解决方案
- MySQL 5.6 中的 TIMESTAMP 和 explicit_defaults_for_timestamp 参数
- MySQL 5.6 中 TIMESTAMP有那些变化
- Mysql学习心得之插入、更新、删除记录
- dynamically creating a set of SQLAlchemy table
- 利用memcached构建高性能的Web应用程序
- Mysql分库分表方案