Tutorial by Examples: sql

If you find that you have multiple servers that need to share session state, storing it in the ASP.NET process memory will not work. For example you may deploy into a web-farm environment with a load balancer that distributes requests in a round-robin fashion. In this environment a single user's req...
In the Project.pro file we add : CONFIG += sql in MainWindow.h we write : #include <QMainWindow> #include <QSql> #include <QDebug> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget...
When using Access you can retrieve data using queries. These queries are built using Structured Query Language (SQL). Understanding SQL is important because it can help build better, more useful queries. When creating queries in Access, you can switch to "SQL View". An example of a "...
The Replace function in SQL is used to update the content of a string. The function call is REPLACE( ) for MySQL, Oracle, and SQL Server. The syntax of the Replace function is: REPLACE (str, find, repl) The following example replaces occurrences of South with Southern in Employees table: FirstN...
public void SaveNewEmployee(Employee newEmployee) { // best practice - wrap all database connections in a using block so they are always closed & disposed even in the event of an Exception // best practice - retrieve the connection string by name from the app.config or web.config (dep...
Exporting a database is a simple two step process: sqlite> .output mydatabase_dump.sql sqlite> .dump Exporting a table is pretty similar: sqlite> .output mytable_dump.sql sqlite> .dump mytable The output file needs to be defined with .output prior to using .dump; otherwise, the...
This example shows how to create a table, insert data, and select from the database using SQLAlchemy Core. For information re: the SQLAlchemy ORM, see here. First, we'll need to connect to our database. from sqlalchemy import create_engine engine = create_engine('sqlite://') The engine is ...
Some applications that use Hibernate generate a huge amount of SQL when the application is started. Sometimes it's better to enable/disable the SQL log in specific points when debugging. To enable, just run this code in your IDE when you are debugging the aplication: org.apache.log4j.Logger.getLog...
The first thing you need to do is create a connection to the database using the connect method. After that, you will need a cursor that will operate with that connection. Use the execute method of the cursor to interact with the database, and every once in a while, commit the changes using the comm...
SQLite is a lightweight, disk-based database. Since it does not require a separate database server, it is often used for prototyping or for small applications that are often used by a single user or by one user at a given time. import sqlite3 conn = sqlite3.connect("users.db") c = con...
This example shows how to create a table, insert data, and select from the database using the SQLAlchemy ORM. For information re: SQLAlchemy Core, see here. First things first, we need to connect to our database, which is identical to how we would connect using SQLAlchemy Core (Core). from sqlalch...
General Using the package RMySQL we can easily query MySQL as well as MariaDB databases and store the result in an R dataframe: library(RMySQL) mydb <- dbConnect(MySQL(), user='user', password='password', dbname='dbname',host='127.0.0.1') queryString <- "SELECT * FROM table1 t1 JO...
Data can be exported using copy command or by taking use of command line options of psql command. To Export csv data from table user to csv file: psql -p \<port> -U \<username> -d \<database> -A -F<delimiter> -c\<sql to execute> \> \<output filename with path&gt...
USE msdb Go SELECT dbo.sysjobs.Name AS 'Job Name', 'Job Enabled' = CASE dbo.sysjobs.Enabled WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' END, 'Frequency' = CASE dbo.sysschedules.freq_type WHEN 1 THEN 'Once' WHEN 4 THEN 'Daily' ...
Postmodern is a library to interface the relational database PostgreSQL. It offers several levels of access to PostgreSQL, from the execution of SQL queries represented as strings, or as lists, to an object-relational mapping. The database used in the following examples can be created with these SQ...
In order to use compression over the wire for a faster transfer, pass the --compress option to mysqldump. Example: mysqldump -h db.example.com -u username -p --compress dbname > dbname.sql Important: If you don't want to lock up the source db, you should also include --lock-tables=false. But ...
gunzip -c dbname.sql.gz | mysql dbname -u username -p Note: -c means write output to stdout.
When we want to change root password in windows, We need to follow following steps : Step 1 : Start your Command Prompt by using any of below method : Perss Crtl+R or Goto Start Menu > Run and then type cmd and hit enter Step 2 : Change your directory to where MYSQL is installed, In my case i...
Normally Android-SQLiteOpenHelper does not allow fully qualified path names where the database should be stored. So public database files are not possible. You can use the SQLiteOpenHelper with a custom path if you provide a custom ContextClass and if you have write access in the target directory. ...
Declare JNDI resource in tomcat's server.xml, using the Tomcat JDBC connection pool: <GlobalNamingResources> <Resource name="jdbc/DatabaseName" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" auth="Container" ...

Page 3 of 10