emp

Oracle 学习(三)多表联查

房东的猫 提交于 2019-12-03 08:22:58
目录 Oracle 学习(三)多表联查 一、99语法 二、至少两种方式行转列 三、分页 Oracle 学习(三)多表联查 @ 一、99语法 Oracle学习(二)中我们学习了92语法,现在我们学习一下99语法 sql 1999语法 1.1.cross join 笛卡尔积 select * from emp cross join dept; 1.2.natural join 自然连接 当两个表不具有相同列名,进行cross join,具有相同列名,自动匹配 select * from emp e natural join dept d; 1.3.on子句,添加链接条件,相当于92语法的等值连接 相当于92语法的等值连接 select * from emp e join dept d on e.deptno=d.deptno 相当于92语法的非等值连接 select * from emp e join salgrade sg on e.sal between sg.losal and sg.hisal 1.4.left outer join 左表中数据全部显示,游标没有数据直接显示空 select * from emp left outer join dept d on e.deptno=d.deptno 1.5.right outer join 右表全部显示,没有数据显示空

SQLSERVER SQL性能优化

北城以北 提交于 2019-12-03 03:35:07
SQLSERVER SQL 性能优化系列      1. 选择最有效率的表名顺序 ( 只在基于规则的优化器中有效 )       SQLSERVER 的解析器按照从右到左的顺序处理 FROM 子句中的表名,因此 FROM 子句中写在最后的表(基础表 driving table )将被最先处理,在 FROM 子句中包含多个表的情况下,必须选择记录条数最少的表作为基础表,当 SQLSERVER 处理多个表时,会运用排序及合并的方式连接它们,    首先,扫描第一个表( FROM 子句中最后的那个表 ) 并对记录进行排序;然后扫描第二个表( FROM 子句中最后第二个表 ) ;最后将所有从第二个表中检索出的记录与第一个表中合适记录进行合并    例如 : 表 TAB1 16,384 条记录表 TAB2 5 条记录,选择 TAB2 作为基础表 ( 最好的方法 ) select count(*) from tab1,tab2 执行时间 0.96 秒,选择 TAB2 作为基础表 ( 不佳的方法 ) select count(*) from tab2,tab1 执行时间 26.09 秒; 如果有 3 个以上的表连接查询,那就需要选择交叉表( intersection table )作为基础表,交叉表是指那个被其他表所引用的表      例如 :    EMP 表描述了 LOCATION 表和

Self Join to get employee manager name

匿名 (未验证) 提交于 2019-12-03 02:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hello I have a Employee Table with following columns Emp_id, Emp_Name and Mgr_id. I am trying to create a view which will list Emp_id, Emp_name, Mgr_id and Mgr_name (by cross joining the Employee table). I tried outer join, inner join etc, but I am not able to get it right. Any help is highly appreciated. CREATE TABLE [dbo].[tblEmployeeDetails]( [emp_id] [bigint] NOT NULL, [emp_name] [nvarchar](200) NULL, [emp_mgr_id] [bigint] NULL, CONSTRAINT [PK_tblEmployeeDetails] PRIMARY KEY CLUSTERED ( [emp_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS

PL/SQL process: issue with wording

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to create a page process in Oracle APEX 4.1. Specifically, When a button on this page is process submitting the page, I want this PL/SQL query to work. I don't have much of an understanding of PL/SQL and am looking to find out how to figure this issue out. What I want the query to do: I would like this page process to loop through each row in the EMPLOYEE table that I have in a database for APEX. For each row, I want to move the username, group and password into their own variables, and then to create an APEX user using the APEX

How can I find which tables reference a given table in Oracle SQL Developer?

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In Oracle SQL Developer , if I'm viewing the information on a table, I can view the constraints, which let me see the foreign keys (and thus which tables are referenced by this table), and I can view the dependencies to see what packages and such reference the table. But I'm not sure how to find which tables reference the table. For example, say I'm looking at the emp table. There is another table emp_dept which captures which employees work in which departments, which references the emp table through emp_id , the primary key of the emp

How to call Oracle Function or Procedure using Hibernate (EntityManager) or JPA 2

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an Oracle function which return sys-refcursor and when I call this function using Hibernate 4, I am getting the following exception. Hibernate: { ? = call my_function(?) } org.hibernate.exception.GenericJDBCException: could not execute query javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1360) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288) at

Oracle text search on multiple tables and joins

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following SQL statement. select emp_no,dob,dept_no from v_depts where catsearch (emp_no,'abc',NULL) > 0 or catsearch (dept_no,'abc',NULL) > 0 where v_depts is a view. Now I would like to add one or more tables as join so that I can do text search on columns e.g. employee_details contains employee information and I can join with emp_no I have created index on employee_details table for emp_name column, however I am not able to join with v_depts to search because I modify my sql statement as select a.emp_no,a.dob,a.dept_no from v

Spark sql issue with columns specified

匿名 (未验证) 提交于 2019-12-03 01:36:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: we are trying to replicate an oracle db into hive. We get the queries from oracle and run them in hive. So, we get them in this format: INSERT INTO schema.table(col1,col2) VALUES ('val','val'); While this query works in Hive directly, when I use spark.sql, I get the following error: org.apache.spark.sql.catalyst.parser.ParseException: mismatched input 'emp_id' expecting {'(', 'SELECT', 'FROM', 'VALUES', 'TABLE', 'INSERT', 'MAP', 'REDUCE'}(line 1, pos 20) == SQL == insert into ss.tab(emp_id,firstname,lastname) values ('1','demo','demo') -----

selecting a range of elements in an array spark sql

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use Spark-shell to do the below operations Recently loaded a table with an array column in spark-sql . Here is the ddl for the same: create table test_emp_arr{ dept_id string, dept_nm string, emp_details Array } the data looks something like this +-------+-------+-------------------------------+ |dept_id|dept_nm| emp_details| +-------+-------+-------------------------------+ | 10|Finance|[Jon, Snow, Castle, Black, Ned]| | 20| IT| [Ned, is, no, more]| +-------+-------+-------------------------------+ i can query the emp_details column

ValueError Expected singleton , Odoo8

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been working on a module in Odoo8 on Ubuntu 14.04. I have come up to a strange issue when saving a form record based on some One2many fields. The error says ValueError Expected singleton: hr.employee.pay.change(84, 85) My Python code is as below class hr_employee_pay_change(models.Model): _name='hr.employee.pay.change' hr_payroll_change_ids = fields.Many2one("employee.salary.change", "Employee", ondelete="cascade") @api.onchange('emp_basic', 'emp_allowance') @api.depends('emp_basic', 'emp_allowance') def _current_total(self): self.emp