一、創建學生表 二、插入數據 三、查詢數據 (一)查詢所有數據 SELECT * FROM STUDENTS; (二)查詢出每個學員的姓名和考試成績 SELECT STU_NAME,STU_SCORES FROM STUDENTS; (三)查詢出考試不及格的學生的信息 SELECT STU_ID,S ...
一、創建學生表
CREATE TABLE STUDENTS( STU_ID NUMBER(10) CONSTRAINTS PK_STUS_ID PRIMARY KEY, STU_NAME VARCHAR2(20) NOT NULL, STU_SCORES NUMBER(3) )
二、插入數據
INSERT INTO STUDENTS VALUES(001,'張三',56); INSERT INTO STUDENTS VALUES(002,'李四',98); INSERT INTO STUDENTS VALUES(003,'王五',40); INSERT INTO STUDENTS VALUES(004,'趙六張',60); INSERT INTO STUDENTS VALUES(005,'小翠',100);
三、查詢數據
(一)查詢所有數據
SELECT * FROM STUDENTS;
(二)查詢出每個學員的姓名和考試成績
SELECT STU_NAME,STU_SCORES FROM STUDENTS;
(三)查詢出考試不及格的學生的信息
SELECT STU_ID,STU_NAME,STU_SCORES FROM STUDENTS WHERE STU_SCORES<60;
(四)查詢姓名包含“張”的學生的信息(用模糊查詢)
SELECT STU_ID,STU_NAME,STU_SCORES FROM STUDENTS WHERE STU_NAME LIKE '%張%';
(五)查詢所有學生的信息並按學習成績降序排序
SELECT STU_ID,STU_NAME,STU_SCORES FROM STUDENTS ORDER BY STU_SCORES DESC;