`

表的创建、数据添加、修改

阅读更多

一、表的创建

       建一个简单的学生表(有学号,姓名,性别,类型)

     create table Student( stu_id integer primary key,

                                        stu_num integer,

                                        stu_name varchar2(10),

                                        stu_sex varchar2(2),

                                        stu_type integer default '0' );

       包含的部分为:

                               1.存储数据类型的选择 常用的

                                     字符串:char()/varchar2()

                                     数 字:number(p,s)/integer()

                                     日 期:date

                                     二进制:clob BLOB (对二进制类型用法还不清楚)

                                2.一些约束

                                     primary key

                                     foreign key   (http://www.w3school.com.cn/sql/sql_foreignkey.asp

                                     unique

                                     not null

                                    check            (http://www.w3school.com.cn/sql/sql_check.asp

                               3.默认值得设定

                                    default

                               4.序列的创建用于自增长。

                                     CREATE SEQUENCE stu_id

                                                 INCREMENT BY 1   -- 每次加几个

                                                 START WITH 0    -- 从1开始计数

                                                 NOMAXVALUE    -- 不设置最大值

                                                 NOCYCLE      -- 一直累加,不循环

                                                 NOCACHE ;

 二、添加数据 查询数据

         (1)

 

         (2)



 三、表中列的修改

        时间获取的格式:http://www.cnblogs.com/ajian/archive/2009/03/25/1421063.html

     

 列的添加


 列的属性修改

alter table Student

modify stu_type number

列重命名

alter table Student

        rename column stu_join to stu_close

表重命名

alter table Student rename to yt_Student

列的删除

alter table Student

drop column Stu_open

四、表中记录的修改


  删除里面的数据

delete from Student  where stu_id='4'

删除整个数据

delete from table_name

delete * from table_name

truncate table table_name   (速度快,释放空间)

五、表的删除

drop table table_name

  • 大小: 9.5 KB
  • 大小: 11.7 KB
  • 大小: 15 KB
  • 大小: 9.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics