MySQL: Stored procedures - mysql

We are at the beginning to build up our site. Maybe you should check it out first to understand our problem: www.erasmusinn.com
Basically we are thinking about to use MySQL for stored procedures or not.
We only need to insert and update our database. Since we are planning to have thousands of database entities, it is very important that we use the most efficient way to update our database.
What do you think? Should we use MySQL?

Personally i would recommend PostgreSQL. It's free to use and easy to migrate from MySQL, and you can build your own functions, views, and have data relations.

Related

Any reason not to put stored procs independent of specific database in mysql's mysql database?

I've never wanted to touch the database actually named "mysql" (the one with tables proc, slow_log, user, etc) unless doing something officially supported with it. By this, I mean I wouldn't create new tables in it, etc.
But, if I'm creating a few stored procedures that operate on any database and aren't specific to a single one, is it appropriate to store those to the "mysql" database, or would it be better to create a "genericStoredProcs" database to put them in that had no tables?
I would not recommend adding any objects to the mysql database.
It might be possible to do that, and it might be supported. But I wouldn't take that risk. That's just asking for trouble. Just let the mysql database be what it's supposed to be, let it do what it's supposed to do, and don't muck with it.
If you need a database to store "shared" objects, then create a new database, and grant appropriate privileges.

Can I use either SQL, MySQL or SQLite to read a SQL database?

I'm not very versed on databases, so thismight sound wrong to some of you: Can I use SQL, MySQL and/or SQLite to read the same database? If so, are there commands or instructions I should keep an eye on to not make a mess on the tables?
Thanks in advance!
sql is a language. sqlite and mysql are database engines.
Both SQLite and MySQL (as far as any SQL engines) allows SQL language to manipulate database content (with some engine specific ).
So you may use SQL to read a MySQL or SQLite database. But be aware that SQL use in each is engine dependent. For instance, in SQLite you may use shell application, c wrapper, ... For MySQL you may use php wrapper, ...

Mysql Stored Procedure use

We have a large database and we do manipulations on it ever day by using the basic mysql queries.
Can anyone please tell me, what is the use of Mysql Stored Procedures?
The real use of the Stored Procedures comes into picture when have any application accessing database.
For example: Imagine that you have written all your database operations in the form of queries in your data access code.
Suppose, that you need to make any change to query , then you need to rebuild and redeploy the entire application in order see your changes.
But, if you are using stored procs and refering them in application, you can just make changes in your database with out need for redeploying the application.
So, obviously better security , maintainability and much more
Note: This is one scenario where stored procs are better than normal queries.
Usage of Stored Procs also avoids SQL Injection Attacks
In very simple words, stored procedures allow you to store your quires along with database, you can combine multiple quires in single procedure. now whenever you want to execute those quires just "CALL yourProcedure;"
Need to perform specific query daily ?
Read about MySQL events = stored procedures with scheduling capability !
https://dev.mysql.com/doc/refman/5.1/en/events.html

SQL Server - update schema of one db from another

I have two databses on a SQL Server -- one for development (call it "TestData"), and one for production (call it "LiveData"). I make changes to TestData -- typically adding tables or adding new fields to existing tables (rarely dropping anything) and creating or modifying Stored Procedures. At some point, I would like to update the LiveData tables, stored procedures, etc. with the changes made to TestData. I only want this to affect the schema, not the actual data. What is the best way to do this? I am new to SQL Server, so the more detailed the explanation, the better.
edit: I know there are third-party programs out there, but I'm looking into ways to do this without a separate software, just using scripts, etc.
You might want to take a look at redgate SQL Compare.
DBComparer is a great free utility to compare schemas. It is a little buggy and crashes sometimes, but other than that it works great.

What is the correct LINQtoSQL-ish way to do a table truncate?

I have a project with a formidable data access layer using LinqtoSQL for just about anything touching our databases. I needed to build a helper class that bridges some common crud operations from CLSA objects to LinqToSql ones. Everything has been operating swimmingly until I needed to do a truncate on a table and all I had were “delete” methods.
Uh-oh. A quick search reveals that some people are using YourContext.ExecuteCommand(), which is nice and all, but I am trying to go “t-sql-less” as much as possible these days.
Is there a LINQ way to perform a truncate on a table? Or am I just clueless?
This is not possible without doing a custom T-SQL query. Doing a .Delete() and SubmitChanges afterwords would, as you probably already know, result in a DELETE statement.
Of course you could create a stored procedure that truncates the table, and then call the procedure from LINQ, but that isn't really what you're looking for I believe.
You can do something like this:
yourDataContext.ExecuteCommand("TRUNCATE TABLE YourTable");