zoukankan      html  css  js  c++  java
  • Oracle 数据库基本语句

    ---管理员登录
    conn sys/oracle@orcl as sysdba;
    --解锁scott方案
    alter user scott account unlock;
    --scott登录
    conn scott/tiger@orcl as normal;

    例题:

    创建表 temp id nubmer(8) names varchar2(20) age number(8)
    create table temp(
    id number(8),
    names varchar2(20),
    age number(8)
    );

    1 增加列 address(30)
    alter table temp add address varchar2(30);

    2 将地址列 长度修改为50
    alter table temp modify address varchar2(50);

    3 删除地址列
    alter table temp drop column address;

    4 增加一条数据 1,'张三',30
    insert into temp values(1,'张三',30);

    5 再增加一个数据 '王五'
    insert into temp(names) values('王五');

    6 将王五的年龄设置为25
    update temp set age=25 where names='王五';

    7 将标号是1的人的 姓名修改为李强,年龄修改为33
    update temp set names='天佑',age=60 where id=1;

    8 将王五删除
    delete from temp where names='王五';

    9 查询所有的数据
    select * from temp;

    10 删除temp表
    drop table temp;

    在Oracle 中效果如下:

    SQL> create table temp(
    2 id number(8),
    3 names varchar2(20),
    4 age number(8)
    5 );
    Table created

    SQL> select * from temp;
    ID NAMES AGE
    --------- -------------------- ---------

    SQL> alter table temp add address varchar2(30);
    Table altered

    SQL> select * from temp;
    ID NAMES AGE ADDRESS
    --------- -------------------- --------- ------------------------------

    SQL> alter table temp modify address varchar2(50);
    Table altered

    SQL> select * from temp;
    ID NAMES AGE ADDRESS
    --------- -------------------- --------- --------------------------------------------------

    SQL> alter table temp drop column address;
    Table altered

    SQL> select * from temp;
    ID NAMES AGE
    --------- -------------------- ---------

    SQL> insert into temp values(1,'张三',30);
    1 row inserted

    SQL> insert into temp(names) values('王五');
    1 row inserted

    SQL> select * from temp;
    ID NAMES AGE
    --------- -------------------- ---------
    1                   张三                        30
                         王五

    SQL> update temp set age=25 where names='王五';
    1 row updated

    SQL> select * from temp;
    ID NAMES AGE
    --------- -------------------- ---------
    1                       张三                30
                             王五                25

    SQL> update temp set names='天佑', age=60 where id=1;
    1 row updated

    SQL> select * from temp;
    ID NAMES AGE
    --------- -------------------- ---------
    1                       天佑                 60
                             王五                 25

    SQL> delete from temp where names='王五';
    1 row deleted

    SQL> select * from temp;
    ID NAMES AGE
    --------- -------------------- ---------
    1                      天佑                   60

    SQL> drop table temp;
    Table dropped

    SQL> select * from temp;

    select * from temp
    ORA-00942: 表或视图不存在

  • 相关阅读:
    转:wcf大文件传输解决之道(1)
    转:WCF传送二进制流数据基本实现步骤详解
    创建一个简单的WCF程序2——手动开启/关闭WCF服务与动态调用WCF地址
    创建一个简单的WCF程序
    转:【专题十二】实现一个简单的FTP服务器
    转:【专题十一】实现一个基于FTP协议的程序——文件上传下载器
    转:【专题十】实现简单的邮件收发器
    转:【专题九】实现类似QQ的即时通信程序
    转:【专题八】P2P编程
    转:【专题七】UDP编程补充——UDP广播程序的实现
  • 原文地址:https://www.cnblogs.com/mumuda/p/6442455.html
Copyright © 2011-2022 走看看