FAQ Database Discussion Community


Stimulate SQL like query tool in python/C++

python,sql,python-2.7,rdbms,sql-parser
Implement SQL like query tool where from STDIN following things have to be read in the given order:- 1. Number of rows of the table (n) and Number of queries (q). 2. Table fields separated by Comma. 3. n line containing table rows of the table 4. q queries where...

Columntype of a column in a view

teradata,rdbms
Is there any way to find the column type of the columns in a view. For example for tables we can fire select Columntype from dbc.tables where tablename=:name and databasename=:name; But for views the above query always returns null value. ...

How to maintain author order in database of citations

database,sqlite,database-design,rdbms
I am writing a program to help authors maintain lists of references for their research. It must be possible to reconstruct citations in various styles from the database. In the database, I maintain a many-to-many relation between authors and the rest of the reference (title, year of publication, etc.) using...

How to update the rows that are not identical in terms of data in a tableB from tableA given that table structure are same in oracle?

database,oracle,plsql,rdbms
Basically I've two tables with almost 46 columns now I wanted some PL/SQL script that can update the row if found unequal from a source table A to table B ( which needs to be updated) there is one primary key on the basis of which comparison will take place...

Is it possible to give condition in MYSQL database column?

mysql,sql,database,rdbms
I am using MYSQL database for my application. Is it possible to give condition in each columns to accept values within the range. For example, Lets say I am having column 'age' of integer type in a table. During insert statement this column should accept value only from 0-100. i.e...

What happens to sql views, if database is moved to another server

mysql,views,rdbms
I have created a view in my current database. But now I'm moving the database to another server. Normally I'm taking the dump, but not sure about views. Will they come when I import the dump and work as per the view? Or I need to create view again?...

Expensive query on database side

sql,rdbms
Let's consider this two tables: | Person | ---------------- | ID | Name | _________________ | 1 | alice | | 2 | bob | | ... | ... | | 99 | zach | | PersonFriend | ---------------- | ID |FriendID| _________________ | 1 | 2 | | 2...

adding a where condition for one criteria in sql query

sql,sql-server,sql-server-2008,rdbms
I need to add a where condition for a SQL query , means when the dept id become 9 only i need that where condition , else i dont required. i have written the below query , is the approach is correct? SELECT b.DeptId, b.DeptName, a.SurveyID, a.SurveyName, a.Status, a.AllUsers, IsNull(a.SelectedUsers,'')...

Why I can't perform this simple insert operation? How can I solve this date format issue?

sql,database,oracle,oracle11g,rdbms
I am not so into database and I have the following problem trying to implement a simple insert query that involve a date field on an Oracle database. So I have a table named FLUSSO_XMLSDI that have the following structure (this is the result of a select *): NUMERO_FATTURA DATA_EMISSIONE...

Auto-COmmit of DDL

mysql,transactions,persistence,rdbms,ddl
I read that "CREATE TABLE" and "DROP TABLE" statements are auto-commit. I am trying to understand their behaviour for the below scenario: conn.setAutoCommit(false); stmt = conn.createStatement("CREATE TABLE ..."); conn.commit(); In the above case, would setting autoCommit to false would have any impact on CREATE TABLE auto-commiting. If conn.setAutoCommit(false) does override...

Accessing comments in RDBMS through sql query in Oracle database

sql,oracle,rdbms
Is there a way to access comments stored in RDBMS through sql query in Oracle database? I am particularly interested in comments made on stored procedures, triggers etc. I am aware of the ALL_TAB_COMMENTS existence, but need to gain access to comments on not only tables and views.

Using Foreign Keys, but showing another column (not id) during a query in MySQL

mysql,database,foreign-keys,rdbms
I have a question regarding foreign keys. I have searched for the answer and was unable to location one. I have a table 'projects' that has the column 'owner_id' which references 'managers.owner_id' as a foreign key. Would it be possible to reference 'managers.owner_id' as a foreign key, but show the...

Can you Sessionize Weblogs in an RDBMS

sql,database,postgresql,hadoop,rdbms
Just a general question. Can you sessionize logs in an RDBMS? For example, say you just have three columns 1) timestamp 2) URL 3) UserID is it possible to sessionize the logs based of X minutes of activity in a traditional RDBMS. The output might look like four columns 1)...

Relational Algebra( The pizza conundrum)

database,rdbms,relational-algebra
I came across a practice paper on relational algebra of Stanford University with relations as:- Person ( name, age, gender ) name is a key. Frequents ( name, pizzeria ) (name, pizzeria) is a key. Eats ( name, pizza ) (name, pizza) is a key. Serves ( pizzeria, pizza, price...

Mysql Query error in where clause on left join

php,mysql,sql,laravel,rdbms
Sorry for the basic question: select `plans`.`name`, `A`.`subscription_id`, `A`.`amount`, `A`.`created_date`, `A`.`end_date`, `A`.`subscription_status`, `users`.`email`, `A`.`plan_id`, `A`.`user_id`, `usage`.`created_at` as `usagedate`, COUNT(usage.id) as used_count from `subscriptions` A left join `users` on `users`.`id` = `A`.`user_id` left join `plans` on `A`.`plan_id` = `plans`.`Id` left join `usage` on `A`.`user_id` = `usage`.`user_id` where `usage`.`created_at` between A.created_at and...

How do RDBM’s make working with data more effective than flat files and spreadsheets. [closed]

data,spreadsheet,rdbms,flat-file
Could anyone help me answer this question: How do RDBM’s make working with data more effective than flat files and spreadsheets. ...

How to incement row id with identity to off

sql,.net,sql-server,stored-procedures,rdbms
I am getting this error while i do select. DECLARE @TopID INT SELECT @TopID = MAX([QuestionId]) from [SurveyQuestions]; SELECT @TopID = @TopID + 1 ,[questiontext] ,[DeptID] ,[SurveyID] FROM [SOSS].[dbo].[SurveyQuestions] where surveyid =80 A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations. I...

sql - retrieving order

sql,rdbms
I was explaining my SQL query to a colleague yesterday and he asked me a question I never considered. Let's say I have a table called the_table like this col1 col2 www.toto.com stuff_wedding www.toto.com stuff_boxing www.toto.com stuff_love www.toto.com stuff_wedding My query is : SELECT * FROM the_table WHERE col1 LIKE...

SQL Group column data from joins

sql,sql-server,group-by,rdbms
I need some help with writing SQL query. I've data in the following format coming from a query returned by joining multiple tables. CustID Name AccNo Bank ------ ---- ----- ----- 1 Varun 9848032919 CB 1 Varun 9998887771 COB 1 Varun 9988776655 CB 2 Lokesh 9876543210 COB 2 Lokesh 9282726252...

Nested SQL query with NOT EXISTS

sql,postgresql,rdbms
I've been trying to figure out this question for a while but couldn't get it to work. Relational schema: Airport(name, country) -> name is the primary key Flight(dep_airport, arr_airport) -> both attributes are foreign keys referencing Airport(name) Question is: find Italian airports that do not have any international flights. The...

Can Rails deal with DB uniqueness without index?

mysql,ruby-on-rails,rdbms
I see add_index ~ unique: true statement in schema.rband think uniqueness is constraint for table, not for index.Using index is one of way realizing uniqueness, Programmer should not designate to the RDBMS "how" and index quicken searching but take costs inserting. In fact, is there another way to keep uniqueness...

How to get all the rows from MySQL table which have same values for multiple columns?

mysql,sql,rdbms
I have a table students with columns rollNumber, majorSubject, minorSubject, fullName. Now given a rollNumber how to find all the students who have same majorSubject, minorSubject as the student with the given rollNumber. What I came up with: SELECT * FROM students WHERE majorSubject IN (SELECT majorSubject FROM students WHERE...

Describe transactions and explain the main principles [closed]

database,rdbms
could anyone help me answer this question: Describe transactions and explain the main principles. ...

Does the term NoSQL fit inside a DBMS?

database,nosql,rdbms
According to wikipedia, a Database Management System consists of four main types: 1 Hierarchical DBMS 2 Network DBMS 3 Relational DBMS 4 Object-oriented DBMS I was wondering whether the term NoSQL is also a type of DBMS. If it does not, where does it belong to? Or can't it be...

Duplication of data in explicit authorization

permissions,authorization,relational-database,rdbms
Our current authorization strategy on our site is very tightly coupled to our RDB's schema - which in some ways is a good thing, since it means the permissions available to a user exactly match what he should have, assuming a correct interpretation of the data. So when we query...