Friday, October 9, 2015

Copy an existing MySQL table to a new table


http://www.tech-recipes.com/rx/1487/copy-an-existing-mysql-table-to-a-new-table/

CREATE TABLE recipes_new LIKE production.recipes; 

INSERT recipes_new SELECT * FROM production.recipes;

Wednesday, October 7, 2015

My sql reference : SHOW VARIABLES



My sql reference



https://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

https://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lower_case_table_names

Syntax to view the system variable value in mysql
SHOW [GLOBAL | SESSION] VARIABLES
    [LIKE 'pattern' | WHERE expr]


Ex:  SHOW VARIABLES LIKE 'lower_case_table_names';

Monday, October 5, 2015

Getting (413) Error “Request Entity Too Large”

reference
http://stackoverflow.com/questions/19959273/still-getting-413-request-entity-too-large-even-after-setting-the-web-config

I found the solution looking in another web.config example
This was my web.config:

  
    <binding name="basicHttpsBinding" maxReceivedMessageSize="524288000" />
    <binding name="mexHttpBinding" maxReceivedMessageSize="524288000" />
  </basicHttpBinding>
</bindings>

  <service behaviorConfiguration="ServicioCCMasAvalBehavior" name="ServicioCCMasAval.ServicioCCMasAval">
    <endpoint address="/" binding="basicHttpBinding" contract="ServicioCCMasAval.IServicioCCMasAval" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>


I was missing the bindingConfiguration on the enpoint. Now this is my working webconfig:

  
    <binding name="basicHttpBinding" maxReceivedMessageSize="524288000" />
    <binding name="mexHttpBinding" maxReceivedMessageSize="524288000" />
  </basicHttpBinding>
</bindings>

  <service behaviorConfiguration="ServicioCCMasAvalBehavior" name="ServicioCCMasAval.ServicioCCMasAval">
    <endpoint address="/" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="ServicioCCMasAval.IServicioCCMasAval" />      
  </service>
</services>

Disable constraints in SQL Server tables

http://stackoverflow.com/questions/159038/how-can-foreign-key-constraints-be-temporarily-disabled-using-t-sql



If you want to disable all constraints in the database just run this code:
-- disable all constraints
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
To switch them back on, run: (the print is optional of course and it is just listing the tables)
-- enable all constraints
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
I find it useful when populating data from one database to another. It is much better approach than dropping constraints. As you mentioned it comes handy when dropping all the data in the database and repopulating it (say in test environment).
If you are deleting all the data you may find this solution to be helpful.