---
title: "oracle数据操作篇（sql语句）"
author: "yonghengmoming"
date: "2012-04-13T08:52:37Z"
tags: []
categories: ["数据库"]
slug: "oracle-sql"
draft: false
lastmod: "2012-04-13T08:53:52Z"
id: 1484942
url: "https://weklyd.iteye.com/blog/1484942"
---

创建序列seq\_cqyt，按1递增，从1开始递增，最小值为1（序列在数据库中很常用）：  
create sequence seq\_cqyt increment by 1 start with 1 nomaxvalue minvalue 1;  
删除序列：  
drop sequence seq\_cqyt;

查看指定表的字段信息：  
desc CQYT1--这个是表名，要大写

往表中插入数据：  
insert into cqyt1(id,username,password) values (12,'u2','p2')；  
insert into cqyt1 values (13,'u3','p3');    --数量和顺序必须一模一样  
insert into cqyt1 values (seq\_cqyt.nextval,'u4','p4')    --使用序列，使用后序列自加1  
insert into cqyt1 values (seq\_cqyt.currval,'u4','p4')    --使用序列，使用后序列不自加

按条件删除表中的数据：  
delete from cqyt1 where id = 12 and (username='u3' || password ='p3');  
按条件修改表中的数据：  
update cqyt1 set password = 'p' where id=11；  
按条件查询表中的数据：  
select * from cqyt1 where id=11;

数据的増删改查，技术含量最高的是查，因为查询语句的好坏很多时候对网站访问速度起着非常重要的作用

关于多表查询、行转列、列转行、查询效率的提高，我将陆续补上