In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Basic operation of SQLServer2008
01 connect to the database
Under Win7, first open the SQLServer management tools (start menu / all programs / Microsoft SQLServer 2008/SQL Server Management Studio)
The Connect to Server dialog box pops up.
1 Server type: database engine
2 Server name: 127.0.0.1
3 Authentication: Windows authentication
The server name can also be "(local)", ".", "loacalhost". Use "(local)" when the local network card (driver) is not installed. Note: double quotation marks are not included.
Authentication you can also choose SQLServer authentication with a sa user password
After a successful link, the relevant database will be displayed in object Explorer on the left.
02 create a new database instance
Here we use graphical operations.
Click the "+" sign on the left side of 127.0.0.1, right-click the database-create a new database
Fill in the database name, click finish, and we have set up a database on this machine.
In order to learn to use it here, I have set up a database (ForStudy). It hurts the most to name something.
Then create a new table, look at the screenshot, and click on the new table to display the central display column information.
We can change the name to our own table name in the "Properties" box on the right (default Table_1)
After setting the column information, click the key icon in the left toolbar to set the primary key in the selected column, as follows
Just save it with Ctrl+S
In object Explorer, click to open the table we just created (mine is dbo.student)
Right-click, edit the first 200 rows, and you can add information to the newly created table.
At this time, the table has been built in the database, and we can also add, delete, modify and check the table.
To say a few more words here, the design of the table is very important. In the project of program development, the database must be designed first.
Otherwise, when you need to modify the database on the way to writing the code, you will find how fucked up it is.
03 use query statements to manipulate tables
Click "New query", select which database to operate in, enter our query statement in the central text box, and click execute.
04 generate SQL script
The SQL script is generated to save the current database structure in the form of SQL query statements
The next time you execute the saved SQL script directly, you can restore the database structure at that time. See the figure.
Then select the database instance and the table to save according to the wizard
The generated .sql file is the script we need.
05 database backup, restore
Backup:
Select the database to be backed up in object Explorer, right-click Task-backup, and select backup location
Others are completed on a stand-alone machine according to the default parameters to generate .bak files.
Restore:
In object Explorer, select "Database", right-click to restore the database, and add the previously backed up files
Just be sure.
06 detach database files
Detach the database file so that it can be used on different hosts
Close the previous query text box, right-click "ForStudy"-Task-detach, and display the detach dialog box.
Click "OK" and we have separated the database file from the local computer.
07 additional database
If it can be separated, it must be re-imported.
Right-click "Database" in object Explorer and click "attach"
Select the add button in the pop-up dialog box and select the database file (of the .mdf suffix) to add.
For example, mine is ForStudy.mdf, and then click OK.
These are the three steps if you want to copy your database information to your classmate's machine.
1. Detach database
two。 Copy the database file in .mdf format
3. Import into the database of the new host
Note: it should be no problem to import the low version of the database file to the higher version, but there is a problem with the compatibility from the high version to the low version. You can take a look at this by yourself!
Tips:
Use sqlcmd to change the sa password:
Enter it under CMD (the original password is 123456 new password I2e456)
Sqlcmd-U "sa"-P "123456"-Z "I2e456"
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 213
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.