sql

ORACLe PROCEDURE - AUTHID allowed only in schema level

限于喜欢 提交于 2021-02-19 04:33:59
问题 While trying to create table via procedure, I am facing error like Error(73,9): PLS-00157: AUTHID only allowed on schema-level programs PROCEDURE BCKUP AUTHID CURRENT_USER AS statusmsg VARCHAR2(400); BEGIN --Backup records EXECUTE IMMEDIATE 'CREATE TABLE schemaname.tabname AS SELECT pgm.* FROM XYZ pgm, IJK prf WHERE prf.col1=pgm.col1 AND prf.ID IN(SELECT ID FROM TAB2)'; COMMIT; EXCEPTION WHEN OTHERS THEN statusmsg :='SQL ERRROR CODE ' || SQLCODE|| ' -ERROR- ' ||SQLERRM; dbms_output.put_line(

Oracle 11g - run windows batch file to run multiple sql files in sqlplus

陌路散爱 提交于 2021-02-19 04:02:37
问题 I would like to use a single batch file to execute multiple sql in a sequence.. IE: sql2 script calls a table created by sql1 script.. etc.. here is the batch code I have so far.. it works to run a single sql file but I need it to run the first one and then then next.. thanks in advance. @ECHO OFF echo. echo. SET /P uname=Username: echo. echo. SET /P pass=Password: echo. echo. SET /P mydatabase=Database: echo. echo. set oracle_sid=ins sqlplus -s %uname%/%pass%@%mydatabase% @J:/A/scripts/

cannot login to sql server with new user created

爷,独闯天下 提交于 2021-02-19 03:56:08
问题 I created a login named logintest (SQL Authentication) then i created a user named usertest with this login the user creation is successful, And i changed the authentication mode to mixed mode and also restarted the services SQLSERVERAGENT and MSSQLSERVER and still this error appear when i try to login with the new user created Cannot connect to SARAH. Login failed for user 'usertest'. (Microsoft SQL Server, Error: 18456) 回答1: The login must have CONNECT right given. The login must be enabled

Python: How to update a value in Google BigQuery in less than 40 seconds?

穿精又带淫゛_ 提交于 2021-02-19 03:43:07
问题 I have a table in Google BigQuery that I access and modify in Python using the pandas functions read_gbq and to_gbq . The problem is that appending 100,000 lines takes about 150 seconds while appending 1 line takes about 40 seconds. I would like to update a value in the table rather than append a line, is there a way to update a value in the table using python that is very fast, or faster than 40 seconds? 回答1: Not sure if you can do so using pandas but you sure can using google-cloud library.

SQL: How to select rows that sum up to certain value

寵の児 提交于 2021-02-19 03:43:07
问题 I want to select rows that sum up to a certain value. My SQL (SQL Fiddle): id user_id storage 1 1 1983349 2 1 42552 3 1 367225 4 1 1357899 37 1 9314493 It should calculate the sum up to 410000 and get the rows. Meanwhile it should get something like this: id user_id storage 2 1 42552 3 1 367225 As you can see, 42552 + 367225 = 409777. It selected two rows that are nearly 410000. I have tried everything but it didn't work :( Sorry for my language, I am German. 回答1: You can use a correlated

Get identity of row inserted in Snowflake Datawarehouse

守給你的承諾、 提交于 2021-02-19 03:23:26
问题 If I have a table with an auto-incrementing ID column, I'd like to be able to insert a row into that table, and get the ID of the row I just created. I know that generally, StackOverflow questions need some sort of code that was attempted or research effort, but I'm not sure where to begin with Snowflake. I've dug through their documentation and I've found nothing for this. The best I could do so far is try result_scan() and last_query_id() , but these don't give me any relevant information

How to implement relational equivalent of the DIVIDE operation in SQL Server

♀尐吖头ヾ 提交于 2021-02-19 03:21:08
问题 I was reading relational algebra from one of the textbook. I came across DIVIDE operation. From Wikipedia: The division is a binary operation that is written as R ÷ S. The result consists of the restrictions of tuples in R to the attribute names unique to R, i.e., in the header of R but not in the header of S, for which it holds that all their combinations with tuples in S are present in R. Thus if R is: +----+----+ | A | B | +----+----+ | a1 | b1 | | a2 | b1 | | a3 | b1 | | a4 | b1 | | a1 |

Postgresql: Unique constraint over Union of 2 columns

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-19 02:59:07
问题 I have the following tables: TRANSACTIONS id | amount ------------------ 1 | 100 2 | -100 3 | 250 4 | -250 TRANSACTION_LINKS id | send_tx | receive_tx --------------------------- 1 | 2 | 1 2 | 4 | 2 The send_tx and receive_tx columns in the transaction links table use foreign keys pointing to the ID of the transactions table. This is how I create the transaction links table CREATE TABLE IF NOT EXISTS transaction_links ( id BIGSERIAL PRIMARY KEY, send_id INT NOT NULL UNIQUE REFERENCES

MMC could not created the snap-in SQL Server configuration manager

心不动则不痛 提交于 2021-02-19 02:53:11
问题 When i tried to connect to sql server configuration manager in sql server 2008. It shows error MMC could not create the snap-in. It was working perfectly till last night. What can be the reason, how can i solve it. But in background sql server is working perfect. 回答1: Win button + R , then type mmc and press enter. Choose File->Add/Remove Snap-in . Click Add to Console Root and find the "SQL Server Configuration Manager" You will be able to use it from there or replace existing console by

ADODB SQL Syntax - Access table Inner Join with Excel worksheet

匆匆过客 提交于 2021-02-19 02:36:09
问题 I have a project where users will need to fill out an Excel file and then export the data to an Access database. The data collected in the Excel file will need to be exported in 3 steps: (1) export data set 1 record, (2) query Access for the primary key (auto-number) of the newly imported record, (3) export data set 2 record, which includes the primary key populated as the foreign key. I am able to accomplish the first step by establishing and opening an ADODB connection. However, I am