有三个表如下
users(id,name);
type(id,name);
note(id,title,contents,user_id,author_id,type_id);
其中,user_id是作者、author_id是原创作者都是与users中的id进行关联的,type_id是分类编号,与type的id关联。
现在需要创建一个视图显示note中的id、title、contents、user_id、author_id、type_id、以及user_id、author_id、type_id对应的name。
怎样写sql语句呢?
第1题:
YoucreateaWebpagethatcontainsthefollowingcode.Youneedtoprovidethefollowingimplementation.EachtimetheAddFilebuttonisclicked,anewdivelementiscreated.ThenewdivelementisappendedaftertheotherfileuploaddivelementsandbeforetheAddFilespan.Eachnewelementhasauniqueidentifier.Whichcodesegmentshouldyouuse?()
A.$("#AddFile").click(function(){varid="File"+++lastId;varitem=$(".File:first").clone(true);$("input:file",item).attr({id:id,name:id});item.insertBefore("#AddFile");});
B.$("#AddFile").click(function(){varid="File"+++lastId;$(".File:first").clone(true).attr({id:id,name:id}).insertBefore("#AddFile");});
C.$("#AddFile").click(function(){varid="File"+++lastId;});
D.$("#AddFile").click(function(){varid="File"+++lastId;varitem=$(".File:first").clone(true);$("input:file",item).attr({id:id,name:id});item.insertAfter("input[type=file]");});
第2题:
登录命令后面直接加要执行的sql语句怎么写?
mysql -u root -proot insert into tab (id,name) value ('1','abc')
这样写对不对?
第3题:
某企业的数据库系统中有如下所示的员工关系和仓库关系,每个仓库可有多名员工,但只有一名负责人。
员工关系(employee):
仓库关系(warehouse):
则创建仓库表结构的SQL语句为(58)。
A.CREATE TABLE (employee ID CHAR(2)NOTNULL UNIQUE, name CHAR(30)NOT NULL, address CHAR(40), principal ID CHAR(3));
B.CREATE warehouse(warehouse ID CHAR(2)PRIMARY KEY, name CHAR(30), address CHAR(40), principal ID CHAR(3));
C.CREATE TABLE warehouse(warehouse ID CHAR(2)PRIMARY KEY, name CHAR(30)NOT NULL, address CHAR(40), principal ID CHAR(3), FOREIGN KEY(principal ID)REFERENCES employee(employee ID));
D.CREATE TABIE warehouse(warehouse ID CHAR(2), name CHAR(30)NOT NULL, address CHAR(40), principal ID CHAR(3), PRIMARY REY(warehouse ID), FOREIGN KEY(employee ID)REFERENCES employee(employee ID));
第4题:
INSERT INTO TEST VALUES(‘&ID’,‘&NAME’); 语句在执行时将()
第5题:
下列哪种方式可以在session中保存一个名为"name",值为"newer"的属性()
第6题:
The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) LAST_NAME VARCHAR2 (25) JOB_ID VARCHAR2(10) You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQL statement do you use?()
第7题:
You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?()
第8题:
Examine the structure of the EMPLOYEES and DEPARTMENTS tables: EMPLOYEESColumn name Data type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2 (30) JOB_ID VARCHAR2 (20) SALARY NUMBER MGR_ID NUMBER References EMPLOYEE_ID COLUMN DEPARTMENT ID NUMBER Foreign key to DEPARTMENT ID column of the DEPARTMENTS table DEPARTMENTSColumn name Data type Remarks DEPARTMENT_ID NUMBER NOT NULL, Primary Key DEPARTMENT_NAME VARCHAR2(30) MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table Evaluate this SQL statement: SELECT employee_id, e.department_id, department_name, salary FROM employees e, departments d WHERE e. department_id = d.department_id; Which SQL statement is equivalent to the above SQL statement?()
第9题:
Examine the structure if the EMPLOYEES table: Column name Data Type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) NOT NULL SAL NUMBER MGR_ID NUMBER References EMPLOYEE_ID column DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the DEPARTMENTS table You need to create a view called EMP_VU that allows the user to insert rows through the view. Which SQL statement, when used to create the EMP_VU view, allows the user to insert rows?()
第10题:
CREATE VIEW emp_vu AS SELECT employee_id, emp_name, department_id FROM employees WHERE mgr_id IN (102, 120);
CREATE VIEW emp_vu AS SELECT employee_id, emp_name, job_id, department_id FROM employees WHERE mgr_id IN (102, 120);
CREATE VIEW emp_vu AS SELECT department_id, SUM(sal) TOTALSAL FROM employees WHERE mgr_id IN (102, 120) GROUP BY department_id;
CREATE VIEW emp_vu AS SELECT employee_id, emp_name, job_id, DISTINCT department_id FROM employees;
第11题:
insertintobook(id,title,price)values(1,’java’,100)
insertintobook(title,price)values(’java’,100)
insertintobookvalues(’java’,100)
insertbookvalues(’java’,100)
第12题:
( 难度:中等)在Hive中,以下哪个SQL语句是错误的
A.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
> FROM CUSTOMERS c
> LEFT OUTER JOIN ORDERS o
> ON (ID = o.CUSTOMER_ID);
B.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
> FROM CUSTOMERS c
> RIGHT OUTER JOIN ORDERS o
> ON (ID = o.CUSTOMER_ID);
C.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
> FROM CUSTOMERS c
> FULL OUTER JOIN ORDERS o
> ON (ID = o.CUSTOMER_ID);
D.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
> FROM CUSTOMERS c
> FULL OUTER JOIN ORDERS o
> ON (ID = o.CUSTOMER_ID OR Name = o.Name);
答案:D
第13题:
假设一连锁书店的数据库中有3个表:连锁分店信息表STORES(STOR ID,STOR NAME),书籍销售信息表SALES(STOR ID,TITLE ID,QTY)和书籍信息表TITLES (TITLE ID,TITLE)。要查询各分店销售某书的数量,相应的SQL语句应该是:
SELECT STOR_NAME,QTY,TITLE
FROM TITLES,STORES,SALES
WHERE TITLES.TITLE_ID=SALES.TITLE_ID AND【 】。
第14题:
现有两张数据表(MySQL数据库)如下:
x_pt_info x_user_info
字段 类型 长度 小数位 字段 类型 长度 小数位
user_id int 11 user_id int 11
pt_group int 11 user_name varchar 20
pt_number decimal 10 2 user_work int 1
描述一下这个SQL语句的作用:
SELECT b.user_id as user_id,b.user_name as user_name,round(sum(a.pt_number),2) as ptnum from x_pt_info a,x_user_info b where
a.user_id=b.user_id and a.pt_group=1 and b.user_work=2 group by a.user_id order by ptnum desc
另外,就你的经验,你觉得该语句是否有改进的余地,如有,请阐述。
第15题:
Click the Exhibit button to examine the data of the EMPLOYEES table.Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee‘s manager, for all the employees who have a manager and earn more than 4000?()
A.SELECT employee_id "Emp_id", emp_name "Employee", salary, employee_id "Mgr_id", emp_name "Manager" FROM employees WHERE salary > 4000;
B.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.employee_id "Mgr_id", m.emp_name "Manager" FROM employees e JOIN employees m WHERE e.mgr_id = m.mgr_id AND e.salary > 4000;
C.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.employee_id "Mgr_id", m.emp_name "Manager" FROM employees e JOIN employees m ON (e.mgr_id = m.employee_id) AND e.salary > 4000;
D.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.mgr_id "Mgr_id", m.emp_name "Manager" FROM employees e SELF JOIN employees m WHERE e.mgr_id = m.employee_id AND e.salary > 4000;
E.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.mgr_id "Mgr_id" m.emp_name "Manager" FROM employees e JOIN employees m USING (e.employee_id = m.employee_id) AND e.salary > 4000;
第16题:
要在users表中插入一条新记录,下面语句正确的是()。
第17题:
Examine the structure of the EMPLOYEES and DEPARTMENTS tables: EMPLOYEESColumn name Data type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2 (30) JOB_ID VARCHAR2 (20) SALARY NUMBER MGR_ID NUMBER References EMPLOYEE_ID COLUMN DEPARTMENT ID NUMBER Foreign key to DEPARTMENT ID column of the DEPARTMENTS table DEPARTMENTSColumn name Data type Remarks DEPARTMENT_ID NUMBER NOT NULL, Primary Key DEPARTMENT_NAME VARCHAR2(30) MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table Evaluate this SQL statement: SELECT employee_id, e.department_id, department_name, salary FROM employees e, departments d WHERE e. department_id = d.department_id; Which SQL statement is equivalent to the above SQL statement? ()
第18题:
Examine the structure if the EMPLOYEES table: Column name Data Type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) NOT NULL SAL NUMBER MGR_ID NUMBER References EMPLOYEE_ID column DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the DEPARTMENTS table You need to create a view called EMP_VU that allows the user to insert rows through the view. Which SQL statement, when used to create the EMP_VU view, allows the user to insert rows? ()
第19题:
Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()
第20题:
Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()
第21题:
List<Student>list=new{Id=1,Name=张三};
varstu=newStudent{Id=1,Name=张三};
varstu=new{Id=1,Name=张三};
publicclassvar{}varstu=new{Id=1,Name=张三};
第22题:
SELECT * FROM emp_dept_vu;
SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department _ id;
SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department _ id, job_id;
SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM (salary) > 20000
None of the statements produce an error; all are valid.
第23题:
request.getSession().setAttribute(“name”,newer)
request.getSession().getAttribute(“ID”,id);
request.getSession().setParameter(“ID”,id);
request.getSession().getParameter(“ID”,id)