标签:数据库表 express ber 创建 目标 creat val cin 关键字
CREATE TABLE BOOKS ( B_ID INT NOT NULL UNIQUE, B_NAME VARCHAR2(20), B_PUBLISH VARCHAR2(50), B_PRICE NUMBER DEFAULT 0.00, B_PUBDATE DATE DEFAULT SYSDATE ); |
语法: SELECT 列名1,列名2 FROM <table_name>; SELECT * FROM BOOKINFO; |
语法: INSERT INTO BOOKS(B_ID,B_NAME,B_PUBLISH,B_PRICE,B_PUBDATE) VALUES(1001,‘计算机文化基础‘,‘大众出版社‘,34.6,TO_DATE(‘2017.4.3‘,‘yyyy.mm.dd‘)); INSERT INTO BOOKS(B_ID,B_NAME,B_PUBLISH,B_PRICE,B_PUBDATE) VALUES(1002,‘计算机硬件基础‘,‘科学出版社‘,44.6,TO_DATE(‘2017.4.3‘,‘yyyy.mm.dd‘)); 数据中的NULL值处理: INSERT INTO BOOKS(B_ID,B_NAME,B_PUBLISH,B_PRICE,B_PUBDATE) VALUES(1003,‘数据库基础‘,‘北京大学出版社‘,NULL,NULL); 注意:插入NULL值得数据,前提是表中该字段允许为空值,即创建表示,没有NOT NULL约束; |
创建表时,通过DEFAULT关键字指定列的默认值; INSERT INTO BOOKS(B_ID,B_NAME,B_PUBLISH,B_PRICE,B_PUBDATE) VALUES(1006,‘遥感信息处理‘,‘科学出版社‘,39.0,TO_DATE(‘2017.4.3‘,‘yyyy.mm.dd‘)); INSERT INTO BOOKS(B_ID,B_NAME,B_PUBLISH,B_PRICE,B_PUBDATE) VALUES(1007,‘图形图像处理‘,NULL,29.5,DEFAULT); |
UNIQUE属性在当前表中的该列中的值必须是完全唯一的,并且只能出现一次; |
用户需要根据已有表和视图的记录,将其中特定的数据添加到目标表中; INSERT INTO BOOKS(B_ID,B_NAME,B_PUBLISH,B_PRICE,B_PUBDATE) SELECT BOOKID,BOOKNAME,PUBLISH,PRICE,PUBDATE FROM BOOKINFO; |
语法: UPDATE <table_or_view_name> SET column_name = {expression | default | NULL} WHERE <search_condition> 注意:一定不要忽略WHERE子句,如果没有指明WHERE子句,则数据库表中所有的行的记录都将被更新; UPDATE BOOKS SET B_PUBLISH=‘邮电出版社‘ WHERE B_ID=1007; |
语法: DELETE FROM <table_or_view_name> WHERE search_condition; DELETE FROM BOOKS WHERE B_PUBLISH=’北京’; |
删除BOOKS表中的所有记录; TRUNCATE TABLE BOOKS; |
标签:数据库表 express ber 创建 目标 creat val cin 关键字
原文地址:http://www.cnblogs.com/qlwang/p/6663730.html