database-schema

List all stored procedures with schema name

非 Y 不嫁゛ 提交于 2019-12-03 03:32:34
Can anyone advise on a way to list all stored procedures along with their schema names in a database? Thanks! SELECT [schema] = OBJECT_SCHEMA_NAME([object_id]), name FROM sys.procedures; or SELECT [schema] = SCHEMA_NAME([schema_id]), name FROM sys.procedures; For a specific database, you can just change the context to that database first, or change Marc's query slightly (my queries are no good in this case because they rely on functions that are context-sensitive): SELECT SchemaName = s.name, ProcedureName = pr.name FROM databasename.sys.procedures pr INNER JOIN databasename.sys.schemas s ON

copy database structure without data in mysql (with empty tables)

本秂侑毒 提交于 2019-12-03 03:29:20
问题 Is there any way to copy database structure without data in MySQL, so the new database will be the same as it is copied from, but with empty tables. After getting some suggestions I tried the command, but I am getting syntax error, my username = root and password = nothing . I guess the default one. I am trying following command, mysqldump -u root -p -d xyz_db | mysql -u root -p -Dnew_db what I am missing or misplacing in command? 回答1: mysqldump -u user -ppass -d olddb | mysql -u user -ppass

Mysqldump: create column names for inserts when backing up

旧巷老猫 提交于 2019-12-03 01:34:14
问题 How do I instruct mysqldump to backup with column names in insert statements? In my case I didn’t a normal back up with insert sql’s resulting in LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` INSERT INTO `users` VALUES (1 structure. Now I went ahead and removed a column from the schema in users. After this when I run the backup sql’s I get a column number mismatch error . To fix this how do I go about instructing mysqldump to write column names too? Here is how I do it now mysqldump

Creating PostgreSQL tables + relationships - PROBLEMS with relationships - ONE TO ONE

痴心易碎 提交于 2019-12-03 01:24:50
So I am supposed to create this schema + relationships exactly the way this ERD depicts it. Here I only show the tables that I am having problems with: So I am trying to make it one to one but for some reason, no matter what I change, I get one to many on whatever table has the foreign key. This is my sql for these two tables. CREATE TABLE lab4.factory( factory_id INTEGER UNIQUE, address VARCHAR(100) NOT NULL, PRIMARY KEY ( factory_id ) ); CREATE TABLE lab4.employee( employee_id INTEGER UNIQUE, employee_name VARCHAR(100) NOT NULL, factory_id INTEGER REFERENCES lab4.factory(factory_id), PRIMARY

How do I set the default schema for a user in MySQL

情到浓时终转凉″ 提交于 2019-12-03 00:56:51
Is there a way to set a default schema for each user in MySQL and if so how? Where user x would default to schema y and user z would default to schema a. There is no default database for user. There is default database for current session. You can get it using DATABASE() function - SELECT DATABASE(); And you can set it using USE statement - USE database1; You should set it manually - USE db_name , or in the connection string. If your user has a local folder e.g. Linux, in your users home folder you could create a .my.cnf file and provide the credentials to access the server there. for example:

database schema for timesheet

扶醉桌前 提交于 2019-12-02 21:11:23
Could someone help me with a rough database schema for a timesheet application where the i would be able to Store hours per day for a time period ( 2 weeks ) for different projects. Ex person A can put 3 hours for projectA and 4 hours for projectB on the same day Make it so that its is easy to get a reports on total hours put for a project, or to get total hours on all projects by a certain person EDIT: Another requirement would be that each timesheet for a particular time period for every person needs to have a field indicating that the person has submitted the timesheet and another saying

Database Structure involving dynamic fields

旧街凉风 提交于 2019-12-02 21:08:06
Im working on a project. Its mostly for learning purposes, i find actually trying a complicated project is the best way to learn a language after grasping the basics. Database design is not a strong point, i started reading up on it but its early days and im still learning. Here is my alpha schema, im really at the point where im just trying to jot down everything i can think of and seeing if any issues jump out. http://diagrams.seaquail.net/Diagram.aspx?ID=10094# Some of my concerns i would like feedback on: Notice for the core attributes like area for example, lets say for simplicity the

Database Design for storing Chat Messages between people

怎甘沉沦 提交于 2019-12-02 19:12:35
I am trying to build a messaging/chat system. which can store conversation between two people in a chronological order. Also if User A deletes the conversation User B still should have access the conversation until he wishes to delete them. Inbox - All the messages recieved by the user from various users will be displayed with the latest message from that particular thread. Conversation Screen - Chronological order of the conversation between the User A and User B This is the basic structure of the database i have come up with. Should i store the messages twice in the database ? id to_id from

Data Modeling: Supertype / Subtype

三世轮回 提交于 2019-12-02 18:55:41
Looking to figure out the proper way to model the below requirements. There are 3 types of “parties” to be concerned with, a Fan, a Band, and a BandMember. That BandMember will always be associated with a Band and can also be a Fan of any band. There are common attributes between a Fan, a Band, and a BandMember, but each of these 3 will also have their own unique attributes. A Fan can be a fan of of any Band or none at all This is a small part of a bigger thought but it is creating confusion in expanding the model. I believe it would have to be diagram 2 or some other option since I don't see

Poll Database Schema

旧城冷巷雨未停 提交于 2019-12-02 18:08:33
What is the best database schema for polls? Is one-to-many relationship good for this? I'm thinking about having two tables: poll_questions int id varchar body datetime created_at datetime updated_at poll_answers int id varchar body int votes default 0 int question_id (foreign key to poll_questions.id) datetime created_at datetime updated_at Then there would also be third table for tracking who voted for an answer so users are able to vote only once: poll_voting_history int id int question_id (foreign key to poll_questions.id) int answer_id (foreign key to poll_answers.id) int user_id (foreign