PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.database.mysql > About MySQL scripts
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
About MySQL scripts

Réponse
 
LinkBack Outils de la discussion
Vieux 01/04/2006, 00h58   #1 (permalink)
Karuna
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut About MySQL scripts

Hi,
I am new to MySQL. I want to create a script file which will include a
number of commands and execute it, just like we do in Oracle. Can any
one tell me how to do it?
Suppose I want to create a script called "temp" that will contain say 4
create statement. I want someone to show me how to create that file and
execute it. And how to capture the output in a separate file like we do
in Oracle. And what should be the extension of the souce file.

Thanks.

  Réponse avec citation
Vieux 01/04/2006, 01h40   #2 (permalink)
Bill Karwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: About MySQL scripts

Karuna wrote:
> Hi,
> I am new to MySQL. I want to create a script file which will include a
> number of commands and execute it, just like we do in Oracle. Can any
> one tell me how to do it?


The MySQL software comes with a utility that serves as both an
interactive shell (analogous to Oracle's SQL*Plus) and a tool to run
scripts containing SQL commands.

Read this documentation page and its sub-pages:
http://dev.mysql.com/doc/refman/5.0/en/mysql.html

Specifically, executing SQL script files is documented here:
http://dev.mysql.com/doc/refman/5.0/...-commands.html
http://dev.mysql.com/doc/refman/5.0/en/batch-mode.html

> Suppose I want to create a script called "temp" that will contain say 4
> create statement. I want someone to show me how to create that file and
> execute it. And how to capture the output in a separate file like we do
> in Oracle.


You can capture output just like any other command at the shell level,
with the ">" output redirection feature.

You can also use the "tee" command in your script to specify the output
file.
http://dev.mysql.com/doc/refman/5.0/...-commands.html

You can also use the --tee='filename' option to the mysql command.
Options are documented here:
http://dev.mysql.com/doc/refman/5.0/...d-options.html

Create the file with a text editor. Alternately, create the file by
capturing the output of MySQL's "mysqldump" command-line tool, which
serves as a database backup utility. The output of mysqldump is a SQL
script that contains the CREATE and INSERT commands necessary to
recreate a database. You can run this script with the 'mysql' utility
as described above.

> And what should be the extension of the souce file.


The extension is not important. My habit is to use ".sql", but the
mysql client utility doesn't require any specific extension on the file.

Regards,
Bill K.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h13.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07356 seconds with 10 queries