微博資料庫

2021-09-24 20:53:33 字數 2386 閱讀 9909

use master;

goif db_id (n'microblogdb') is not null

--n '.... '代表是unicode   字串

/*刪除資料庫 資料庫名一般放在master的sysdatabases中。

方法一 用exists(存在)

use mastergo

if exists(select * from sysdatabases where name = '資料庫名')

drop database 資料庫名go

方法二 db_id存在sqlserver2000以後的版本

use mastergo

if db_id(n'資料庫名') is not

drop database 資料庫名go

*/

drop database microblogdb;

go-- get the sql server data path.

declare @data_path nvarchar(256);

set @data_path = (select substring(physical_name, 1, charindex(n'master.mdf', lower(physical_name)) - 1)

from master.sys.master_files

where database_id = 1 and file_id = 1);

-- execute the create database statement.

execute ('create database microblogdbon(

name = microblogdb_data

,filename = ''' + @data_path + 'microblogdb_data.mdf''

,size = 10mb

,maxsize = 50mb

,filegrowth = 15%

)log on

(name = microblog_log

,filename = ''' + @data_path + 'microblogdb_log.ldf''

,size = 5mb

,maxsize = 25mb

,filegrowth = 5mb

)');

gouse microblogdb;

gocreate table tbuser--使用者表

(userid nvarchar(64)primary key,--使用者id,主鍵

password nvarchar(64),--密碼

question nvarchar(64),--密碼問題

answer nvarchar(64),--密碼問題答案

nickname nvarchar(64),--暱稱

truename nvarchar(64),--真實姓名

*** nvarchar(8) check (*** in ('男','女')),--性別

province nvarchar(16),--省份

city nvarchar(16),--市

blogaddress nvarchar(64),--部落格位址

email nvarchar(64),--電子郵件

qq nvarchar(32),--qq

msn nvarchar(64),--msn

selfintroduction nvarchar(1024),--自我介紹

)alter   table   tbuser   add   regdate   datetime  default   null  --給表新增乙個字段

insert into tbuser

(userid,

password,

question,

answer,

nickname,

truename,

***,

province,

city,

blogaddress,

email,

qq,msn,

selfintroduction

)values

('lianqidi'/* userid */,

'123456'/* password */,

'我叫什麼?'/* question */,

'連齊俤?'/* answer */,

'獨釣寒江雪'/* nickname */,

'連齊俤'/* truename */,

'男'/* *** */,

'福建省'/* province */,

'福州市'/* city */,

''/* blogaddress */,

新浪微博,騰訊微博mysql資料庫主表猜想

使用者資訊表 t user info 欄位名稱 位元組數 型別 描述 user id 4uint32 使用者編號 主鍵 user name 20char 20 名稱msg count 4uint32 發布訊息數量,可以作為t msg info水平切分新錶的auto increment fans co...

微博明細資料

資料介紹 此資料api返回結果包括 文章唯一id 介面列表 微博分析 介面位址 支援格式 json 請求方式 get請求示例 請求引數說明 編號名稱型別 是否必填備註1 string true 2articleid string true 文章id 3secondspread boolean fal...

python 抓取微博資料

匯入需要的模組 import urllib.request import json 定義要爬取的微博大v的微博id id 1259110474 設定 ip proxy addr 122.241.72.191 808 定義頁面開啟函式 獲取微博主頁的containerid,爬取微博內容時需要此id d...